var num; //declared var num2 = 2; //declared and initialized var num_3 = 2.456; var something = "hello tomtom";
Variables are case sensitive, therefore var num and var NUM are two different variables.
- Boolean: These can be either true or false
var something = true;
- String: A string of characters or a character.
var something1 = "hello"; var something2= "you are learning a great tech";
var p = 1; //decimal number var q = 0377 //a number starting with 0 is considered an octal number in JS var r = 0xA2 //a number starting with 0x is considered an hexadecimal number var s = 1e+1 // this is 1*10^1 = 10 var t = 2e+3 // this is 2*10^3 = 2000 var u = 2e-3 // this is 2*10^-3 = 0.002 var v = Infinity //to represent a large positive number var w = -Infinity //to represent a large negative number var x = NaN
>>>foo foo is not defined typeof foo; // returns "undefined"
The same is true for uninitialized value as well.
var something typeof something; // returns "undefined"