File tree Expand file tree Collapse file tree
JavaScript Interview/Most Imp MCQ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ let x ;
2+ console . log ( typeof x ) ; // "undefined"
3+
4+ let y = 10 ;
5+ console . log ( typeof y ) ; // "number"
6+
7+ let z = 10.25 ;
8+ console . log ( typeof z ) ; // "number"
9+
10+ let a = true ;
11+ console . log ( typeof a ) ; // "boolean"
12+
13+ let b = "nilaj" ;
14+ console . log ( typeof b ) ; // "string"
15+
16+ let c = null ;
17+ console . log ( typeof c ) ; // "object" ❗ (this is a JS quirk/bug)
18+
19+ let d = BigInt ( 8 ) ;
20+ console . log ( typeof d ) ; // "bigint"
21+
22+ let e = Symbol ( "hi" ) ;
23+ console . log ( typeof e ) ; // "symbol"
24+
25+
26+
27+
28+ console . log ( typeof NaN ) ; // "number" ❗ (NaN means "Not a Number", but still a number type)
29+
30+ console . log ( typeof Infinity ) ; // "number"
31+
32+ console . log ( typeof [ ] ) ; // "object" ❗ (Array is technically an object)
33+
34+ console . log ( typeof { } ) ; // "object"
35+
36+ console . log ( typeof function ( ) { } ) ; // "function" ✅ (Special case)
37+
38+ console . log ( typeof new Date ( ) ) ; // "object"
39+
40+ console . log ( typeof null ) ; // "object" ❗ (JS bug)
41+
42+
43+ console . log ( isNaN ( NaN ) ) ; // true
44+ console . log ( isNaN ( "hello" ) ) ; // true (because "hello" is not a number)
45+ console . log ( isNaN ( 123 ) ) ; // false
You can’t perform that action at this time.
0 commit comments