AmitDiwan has Published 10740 Articles

NaN and Infinity example in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:23:32

245 Views

Following is the code to implement NaN and Infinity in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;    } ... Read More

How to delete object properties in JavaScript?

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:21:27

222 Views

Following is the code for deleting object properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result, .sample {       font-size: 20px;       font-weight: 500;    } ... Read More

How to create an object and access its properties in JavaScript?

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:18:51

268 Views

Following is the code creating an object and accessing its properties in JavaScript −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result {       font-size: 20px;       font-weight: 500;   ... Read More

Explain hoisting in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:16:02

423 Views

Hoisting allows us to call functions and variables (declared with var) before they are being defined by moving them to the top of their scope before the execution of code begins.Following is the code showing hoisting for variables and functions in JavaScript −Example Live Demo Document ... Read More

How to import and export a module/library in JavaScript?

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:12:59

2K+ Views

Note − To run this example you will need to run a localhost server.Following is the code for importing and exporting a module/library in JavaScript −ExampleINDEX.html Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .result ... Read More

Explain ‘dotAll’ flag for regular expressions in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:09:01

267 Views

The dotAll flag returns true or false depending upon if the s flag has been set in the regular expression or not.Following is the code to implement dotAll flag for regular expressions in JavaScript −Example Live Demo Document    body {       font-family: "Segoe ... Read More

Explain the callback Promise.finally in JavaScript

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:06:56

220 Views

The promise.finally() calls the callback function whether a promise has been fulfilled or rejected. This helps us to do something once the promise has been rejected or resolved.Following is the code for Promise.finally() in JavaScript −Example Live Demo Document    body {       font-family: ... Read More

Named capture groups JavaScript Regular Expressions

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 13:03:30

204 Views

With JavaScript, you can group s part of regular expression. This can be done by encapsulating characters in parentheses.Following is an example −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample, .result {   ... Read More

Lookbehind Assertions JavaScript Regular Expressions

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 12:57:57

178 Views

Lookbehind allows matching a pattern only if there’re something before.Following is an example −Example Live Demo Document    body {       font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;    }    .sample, .result {       font-size: 20px;       font-weight: 500; ... Read More

How can I disable JavaScript click function if link starts with #?

AmitDiwan

AmitDiwan

Updated on 15-Jul-2020 12:57:55

435 Views

For this, use preventDefault() in JavaScript. Following is the JavaScript code −Example Live Demo Document Press Me to see logs Press Me to see logs in console Nothing will happen    $(function(){       $("a:not([href='#'])").click(function(event){          event.preventDefault(); ... Read More

Advertisements