File tree Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Original file line number Diff line number Diff line change @@ -31,17 +31,8 @@ console.log(o3); // yes o3 has been changed//
31
31
32
32
// 17. type of//
33
33
let bar = 42 ;
34
- console . log ( typeof typeof bar ) ;
35
- console . log ( typeof bar ) ;
34
+ console . log ( typeof typeof bar ) ; //returns 'string' because the word number is a string?//
35
+ console . log ( typeof bar ) ; //returns 'number' because the value of bar is 42 which is a number//
36
36
console . log ( bar ) ;
37
37
38
- // 42 is a primitive (ie because it is a number). so you cannot get a typeof of it usually as it has no property.
39
- //but in order to get a typeof, it is temporarily coerced into being an object.
40
- //so then it can return a value ie string (line 34) or number (line 35)
41
- //the created object is then removed into the garbage.
42
-
43
-
44
-
45
-
46
-
47
38
You can’t perform that action at this time.
0 commit comments