Found 10877 Articles for Web Development

How do I create dynamic variable names inside a JavaScript loop?

Shubham Vora
Updated on 20-Jul-2022 08:30:09

13K+ Views

In this tutorial, we will use the dynamic variable names inside the JavaScript loop. The dynamic variables name means it is not hardcoded already, and we can create it according to our needs from some other string values.In JavaScript, there are not many applications of the dynamic variable, but it is needed while developing the real-time application. For example, while developing any application, the programmer wants to store any user-related entity to the variable with the same name as the username. In this scenario, programmers need to create dynamic variables inside JavaScript.Users can also refer to the below examples to ... Read More

Which data is stored in var and how its content is changed in JavaScript?

Amit Sharma
Updated on 13-Sep-2019 07:26:07

55 Views

JavaScript variables are not typed but their values do have a type. The same variable can be assigned new values.ExampleLive Demo                    var a;          document.write(typeof a+"\r");          a = true;          document.write(typeof a+"\r");          a = 5;          document.write(typeof a+"\r");          a = "web";          document.write(typeof a+"\r");          

Must you define a data type when declaring a variable in JavaScript?

Amit Sharma
Updated on 03-Jan-2020 10:54:26

66 Views

In JavaScript, variables are defined using the var keyword followed by the variable name. Before you use a variable in a JavaScript program, you must declare it. Variables are declared with the var keyword as follows.var rank;A data type isn’t needed in JavaScript. Variables in JavaScript are not handled like other strong typed language C++, Java, etc.Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a later point in time when you need that variable.    var name = "Amit";    var rank = 2;

How are variables allocated memory in JavaScript?

Sai Subramanyam
Updated on 30-Jul-2019 22:30:21

257 Views

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 JavaScript program, you must declare it. Variables are declared with the var keyword as follows. var rank; var points; Storing a value in a variable is called variable initialization. You can do variable initialization at the time of variable creation or at a ... Read More

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

Shubham Vora
Updated on 31-Oct-2022 11:27:30

4K+ Views

In this tutorial, we will learn what “javascript: void(0)” means. In English, void means nothing. In a programming language, void means return nothing. “javascript: void(0)” is similar to void. javascript: void(0) means return undefined as a primitive value. We use this to prevent any negative effects on a webpage when we insert some expression. For example, in the case of URL hyperlinks. Hyperlinks open by reloading the page when the user clicks on the link. When you need to run some other code in such cases, you can use javascript: void(0). Let’s split javascript: void(0) with a colon. We get ... Read More

What is the yield keyword in JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 12:12:12

492 Views

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++) {       yield selPlayers[i];    } }After defining a generator function, use it like the following. HHere displayRank() is the generator function −var rank = displayRank(); // // value: 1 alert(rank.next()); // value: 2 alert(rank.next()); // value: 3 alert(rank.next()); // value: 4 alert(rank.next()); // value: undefined alert(rank.next());

How to check if a variable is NaN in JavaScript?

Shubham Vora
Updated on 08-Aug-2022 08:45:55

8K+ Views

In this tutorial, we will learn to check if the variable is NaN in JavaScript. The full form of the NaN is ‘not a number’. The NaN is the reserved keyword in the JavaScript which we can assign to the variable. If users are using the below method to check whether a variable is a number or not, it will not work. var a = "Hello"; let result = a == NaN; // it always returns false. As we have talked that the above method will not work to check for a number because NaN is the reserved keyword. ... Read More

What is NaN in JavaScript?

Abhishek
Updated on 08-Nov-2022 06:40:59

466 Views

In this tutorial, we will learn about NaN in JavaScript. NaN is nothing more than a property of the global object which stands for Not a Number. It is mainly used to check whether the entered value is a number or not. The NaN and Number. NaN both are same, so do not confuse next time if Number. NaN is written in any program as it is similar to NaN. The NaN is a property that is rarely used in any program because it is not a good practice to use NaN to identify anything in the program. There is ... Read More

How to use 'const' keyword in JavaScript?

Abhishek Kumar
Updated on 10-Nov-2022 08:47:01

3K+ Views

We use the const keyword in JavaScript to declare variables whose value can be initialized only at the time of declaration. It is similar functionality of declaring variables as the other keywords provided in JavaScript i.e. var and let. const is short for constant, meaning that the value that resides in the variable is unchangeable. The const keyword in JavaScript It is used to declare variables in JavaScript. The variables created using const follow certain rules. The variable is block scoped. This means that the scope(lifetime) of the variable depends on the place where it has been declared. This ... Read More

Why is 'class' a reserved word in JavaScript?

Rahul Sharma
Updated on 13-Jun-2020 11:44:33

389 Views

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 Specification it is used. The class declaration creates a class −class name [extends] {    // body of class }

Advertisements