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*/
1/*JavaScript data types*/
2//string
3var string = 'ASCII text';
4//int
5var integer = 123456789;
6//float
7var float = 123.456;
8//boolean, can be true or false
9var t = true;
10var f = false;
11//undefined
12var undef;//defaults to undefined
13var undef = undefined;//not common, use null
14//null
15var nul = null;
16//array
17var arr = ['Hello','my','name','is','Dr.Hippo',123,null];
18//object
19var person = {'name':'John Smith','age':27};
20//function
21var fun = function(){
22 return 42;
23}
1//There are 7 data types in JS
2//They're split in two categories - (Primitives and Complex Types)
3
4//Primives
5string, number, boolean, null, undefined
6
7//Complex types
8Object, Function
1
2/*
3
4-----------------------------------------------------------
5 string | number | object | boolean | undefined
6-----------------------------------------------------------
7 ~ ~ ~ ~ ~
8 "Words" 22 [ array ] true -false X
9
10 . . { json } . . undefined
11
12 . . Null . . .
13
14
15
16***
17//Primives
18string, number, boolean, null, undefined
19
20//Complex types
21Object, Function
22
23
24
25
26*/