- undefined
- number
- string
- symbol
- object
- function
- boolean
- null
- Variable names are case sensitive.
- First letter should be alphabet(a), underscore(_), dollor sign($)
- Recommend to use camelCase when declaring a variable.
- Shouldn't be the reserved keyword
break | case | catch | continue
default | delete | do | else
false | finally | for | function
if | in | instanceof | new
null | return | switch | this
throw | true | try | typeof
var | void | while | with
var someVariable;
let thisVariable;
const thatVariable;var a;
console.log(a); // undefinedvar num1 = 12;
console.log(num1); // 12
typeof num1; // "number"var text1 = "Hello World";
console.log(text1); // "Hello World"
typeof text1; // "string"var sym1 = Symbol('foo');
console.log(sym1); // Symbol(foo)
typeof sym1; // "symbol"
Symbol('foo') === Symbol('foo'); // falsevar fruit = ['Apple', 'Banana', 'Orange'];
console.log(fruit); // ["Apple", "Banana", "Orange"]
typeof fruit; // "object"var function1 = new Function('5 + 2');
console.log(myFun);
/*
ƒ anonymous() {
5 + 2
}
*/
typeof myFun // "function"var flag = true;
console.log(flag); // true
typeof flag // "boolean"// foo is known to exist now but it has no type or value
var foo = null;
foo // null
typeof null // "object"
typeof undefined // "undefined"
null === undefined // false
null == undefined // true
null === null // true
null == null // true
null // null
!null // true