Skip to content

Commit 3e10f92

Browse files
authored
Merge pull request lydiahallie#705 from MenaiAla/master
Give a names for the equal operators | Provide the environment of each global variable
2 parents 0ca1d32 + cdea09f commit 3e10f92

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ console.log(b === c);
263263

264264
`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.
265265

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`.
267267

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.`
269269

270270
</p>
271271
</details>
@@ -324,7 +324,12 @@ console.log(greetign);
324324

325325
#### Answer: A
326326

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.
328333

329334
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.
330335

0 commit comments

Comments
 (0)