JavaScript Variables

Variable names in JavaScript are the names given to locations in memory. Consider, the JavaScript variable as a container to hold values. The JavaScript variables are declared with any of the following keywords:

  • var: Added to JavaScript before 2015.
  • let: Added to JavaScript in 2015
  • const: Added to JavaScript in 2015

As you can see above, the let and const keywords were introduced in ES2015 I.E. ES6. For JavaScript usage in the year 2023, we suggest using let. It works for all the major modern web browsers.

Integer Variable in JavaScript

Let us now declare integer variables using the let keyword. Here, we have declared an integer variable:

Output

JavaScript Variables Integer Example

String Variable in JavaScript

Let us now declare string variables using the let keyword. Here, we have declared a string variable:

Output

JavaScript Variables String Example

JavaScript Comments
JavaScript Data Types
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading