- Five primitive types and an object.
Example 1
Boolean - true or false
Number - 1, 1.0
String - "a", 'a'
Null - null
Undefined - undefined
Object - {}, new ObjectExample 2
- typeof(null) is "object".
typeof(1); // number
typeof('a'); // string
typeof(true); // boolean
typeof(undefined); //undefined
typeof(null); // object <--- POINT
typeof({}); // objectundefinedis used by JavaScript Engine to inform you to this is either an uninitialized variable, it's either parameter that is missing from the function parameters list or un unknown property of object.nullis used by a programmer to indicate no value. JavaScript engine never set null for you.
console.log(null==undefined); //true
console.log(null===undefined); // false