-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path5datatypes.js
49 lines (37 loc) · 1.63 KB
/
5datatypes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Note: "typeof": to return the datatype of the variable
// Number datatype -- int, float, long (as implicit objects)
let num = 100
console.log("1) " + num+ " : " + typeof num);
num = 101.15
console.log("2) " + num+" : "+typeof num)
// String datatype
let text="Hello how are you ?"
console.log("3) " + text + " : " + typeof text)
let type1 = "double quotes -- "
let type2 = 'single quotes -- '
let type3 = `back ticks ${text}` // Supports data binding on runtime
console.log("4) " + type1 + type2 + type3) // typeof : string (each)
//Boolean datatype
let t1 = true
let t2 = 1!=0
let t3 = 1=='1'
console.log( "5) " + t1 + " & " + t2 + " & " + t3 + " : " + (typeof 'x'<='y'))
// undefined datatype
let undef // declared but uninitialised --> memory exists but no value
console.log( "6) " + undef + " : " + typeof undef)
// null datatype
let val = null // memory with void value
console.log( "7) " + val + " : " + typeof val)
// Note: Both undefined and null seems same but are completely different
let x = 'Hi buds!'
console.log( "8) " + x*5 + " : " + (typeof x/5) ) // x: Not A Number --> datatype
// Note: "+" don't return NaN ∵('+' supports string concat implicit typecast)
//BigInt datatype
let big1 = 9856312457896325487854254887528765n // n --> explicit notation
let big2 = 9879269763984630734019843019708713 // datatype --> number
console.log( "9) " + big1 + " : " + typeof big1 + " & " + big2 + " : " + typeof big2)
//Object datatype: {} --> notation of js objects
let numObj=100
console.log("10) " + typeof Math)
console.log(typeof numObj + " " + typeof {numObj})
console.log(typeof null)