How are variables allocated memory in JavaScript?

Sai Subramanyam
Published on 23-Jan-2018 06:58:21
JavaScript handling of the variable is different from other programming languages C, C++., Java, etc. Variables in JavaScript can be thought of as named containers. You can place data into these containers and then refer to the data simply by naming the container. Before you use a variable in a ... Read More

What does “javascript:void(0)” mean?

Ali
Ali
Published on 16-Jan-2018 07:36:58
If inserting an expression into a web page results in an unwanted effect, then use JavaScript void to remove it. Adding “javaScript:void(0)”, returns the undefined primitive value.The void operator is used to evaluate the given expression. After that, it returns undefined. It obtains the undefined primitive value, using void(0).The void(0) ... Read More

What is the yield keyword in JavaScript?

Rahul Sharma
Published on 16-Jan-2018 07:35:42
The yield keyword is used in JavaScript to pause and resume a generator function. The value of the expression is returned to the generator's caller.Here are the Examples −function* displayRank () {    var selPlayers= [1, 2, 3, 4];    for (var a = 0; a < selPlayers.length; a++) { ... Read More

How to check if a variable is NaN in JavaScript?

Johar Ali
Published on 16-Jan-2018 06:59:20
NaN is a JavaScript property, which is "Not-a-Number" value. To find out whether value is NaN, use the Number.isNaN() or isNan() method.ExampleHere’s an example to check if a variable in NaN in JavaScriptLive Demo<!DOCTYPE html> <html>    <body>       <button onclick="display()">Check</button>       <p id="test"></p>     ... Read More

What is NaN in JavaScript?

Amit Sharma
Published on 16-Jan-2018 06:57:54
NaN is a JavaScript property, which is "Not-a-Number" value. This shows it is not a legal number.SyntaxHere’s the syntax −Number.NaNExampleTo find out whether value is NaN, use the Number.isNaN() or isNan() method. Here’s an example to check −Live Demo<!DOCTYPE html> <html>    <body>       <button onclick="display()">Check</button>     ... Read More

How to use 'const' keyword in JavaScript?

Ali
Ali
Published on 16-Jan-2018 06:56:00
The value of const remains the same, you can’t change and declare it again. Create a read-only reference with the “const” declaration. With const, you can declare local variables with block scope rather than function scope. Let’ say we have a constant variable a. After declaring a value like a constant ... Read More

Why is 'class' a reserved word in JavaScript?

Rahul Sharma
Published on 16-Jan-2018 06:54:20
The following are the future reserved words, which include ‘class’. These words are used as keywords in proposed extensions and are therefore reserved to allow for the possibility of future adoption of those extensions.class enum extends super const export ImportThe above is defined in the ECMAScript specification.In ECMAScript 6 Language ... Read More

Why JavaScript 'var null' throw an error but 'var undefined' doesn't?

Johar Ali
Published on 16-Jan-2018 06:48:55
The web browser throws an error for “var null” because it is a reserved identifier.You cannot use the following literals as identifiers in ECMAScript −null frue falseundefined A property with no definition. It is not known and not a reserved identifier. Its type is undefined.nullIt is known and a reserved identifier. ... Read More

What are Reserved Words in JavaScript?

Amit Sharma
Published on 16-Jan-2018 06:33:42
Reserved words cannot be used as JavaScript variables, functions, methods, loop labels, or any object names.Here are the reserved words in JavaScript −abstractElseinstanceofswitchbooleanEnumintsynchronizedbreakExportinterfacethisbyteExtendslongthrowcaseFalsenativethrowscatchFinalnewtransientcharFinallynulltrueclassFloatpackagetryconstForprivatetypeofcontinueFunctionprotectedvardebuggerGotopublicvoiddefaultIfreturnvolatiledeleteimplementsshortwhileDoImportstaticwithdoubleInsuper

What are Variable Naming Conventions in JavaScript

Ali
Ali
Published on 16-Jan-2018 06:15:37
While naming your variables in JavaScript, keep some rules in mind. The following are the variable naming conventions in JavaScript −You should not use any of the JavaScript reserved keywords as a variable name. These keywords are mentioned in the next section. For example, break or boolean variable names are not valid.JavaScript ... Read More
Advertisements