You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-3
Original file line number
Diff line number
Diff line change
@@ -263,9 +263,9 @@ console.log(b === c);
263
263
264
264
`new Number()` is a built-in function constructor. Although it looks like a number, it's not really a number: it has a bunch of extra features and is an object.
265
265
266
-
When we use the `==` operator, it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
266
+
When we use the `==` operator (Equality operator), it only checks whether it has the same _value_. They both have the value of `3`, so it returns `true`.
267
267
268
-
However, when we use the `===` operator, both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
268
+
However, when we use the `===` operator (Strict equality operator), both value _and_ type should be the same. It's not: `new Number()` is not a number, it's an **object**. Both return `false.`
269
269
270
270
</p>
271
271
</details>
@@ -324,7 +324,12 @@ console.log(greetign);
324
324
325
325
#### Answer: A
326
326
327
-
It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as `global.greetign = {}` (or `window.greetign = {}` in a browser).
327
+
It logs the object, because we just created an empty object on the global object! When we mistyped `greeting` as `greetign`, the JS interpreter actually saw this as:
328
+
329
+
1.`global.greetign = {}` in Node.js
330
+
2.`window.greetign = {}`, `frames.geetign = {}` and `self.greetign` in browsers.
331
+
3.`self.greetign` in web workers.
332
+
4.`globalThis.greetign` in all environments.
328
333
329
334
In order to avoid this, we can use `"use strict"`. This makes sure that you have declared a variable before setting it equal to anything.
0 commit comments