Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit be8c55d

Browse files
committed
.
1 parent 1d500a3 commit be8c55d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

week2js/3tada15_17.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ console.log(o2);
3030
console.log(o3); // yes o3 has been changed//
3131

3232
// 17. type of//
33-
let bar = 42; // typeof bar would return number//
34-
console.log(typeof typeof bar); // returns string//
33+
let bar = 42;
34+
console.log(typeof typeof bar);
35+
console.log(typeof bar);
36+
console.log(bar);
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.
3542

3643

3744

0 commit comments

Comments
 (0)