1// get type of variable
2
3var number = 1
4var string = 'hello world'
5var dict = {a: 1, b: 2, c: 3}
6
7console.log(typeof number) // number
8console.log(typeof string) // string
9console.log(typeof dict) // object
1var age = 18; // number
2var name = "Jane"; // string
3var name = {first:"Jane", last:"Doe"}; // object
4var truth = false; // boolean
5var sheets = ["HTML","CSS","JS"]; // array
6var a; typeof a; // undefined
7var a = null; // value null
8
1/*
2The latest ECMAScript standard defines nine types:
3
4Six Data Types that are primitives, checked by typeof operator:
5undefined : typeof instance === "undefined"
6Boolean : typeof instance === "boolean"
7Number : typeof instance === "number"
8String : typeof instance === "string"
9BigInt : typeof instance === "bigint"
10Symbol : typeof instance === "symbol"
11Structural Types:
12Object : typeof instance === "object". Special non-data but Structural type for any constructed object instance also used as data structures: new Object, new Array, new Map, new Set, new WeakMap, new WeakSet, new Date and almost everything made with new keyword;
13Function : a non-data structure, though it also answers for typeof operator: typeof instance === "function". This is merely a special shorthand for Functions, though every Function constructor is derived from Object constructor.
14Structural Root Primitive:
15null : typeof instance === "object". Special primitive type having additional usage for its value: if object is not inherited, then null is shown;
16*/
1let length = 16; // Number
2let lastName = "Johnson"; // String
3let x = {firstName:"John", lastName:"Doe"}; // Object