Javascript Data Structure Tutorial - Javascript Variable








Declaring and Intializing

JavaScript variables are global by default.

JavaScript variables don't have to be declared before using.

When a JavaScript variable is initialized without declaration, it becomes a global variable.

Example

To declare a variable in JavaScript, use the keyword var followed by a variable name.

Here are some examples:

var number; 
var name; 
var myNumber
var longValue = 11111;
var rate = 1.2; 
var greeting = "Hello, world!"; 
var flag = false; 
var myValue = 'a';