Variables can be declared with the 'var', 'let' or 'const' keyword.
Variables do not have an explicit data type. There are 3 primitive data types.
Variables do not have a data type until a value is assigned to it and at that point the correct data type is inferred.
The semicolon is optional when statements are followed by a line break.

var myNumber1 = 10;        // number data type 
var myNumber2 = 5.38; // number data type
var myString = "text"; // string data type
var myBoolean = false; // boolean data type

var varData = data;
var varName = "Smith";
var varAge = 26;
var isOdd = false;

All On One Line

The semicolon is required when you have two or more statements on the same line.
This line creates 3 variables and assigns them values

var myObject = new Object(), myString = 'sometext', myNumber = math.random();  

© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext