Skip to content

Commit abce03f

Browse files
fix(q76): 📝 add nodejs to the answer
Update the explanation for Nodejs
1 parent e9c9ac2 commit abce03f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2434,10 +2434,12 @@ Therefore, `firstName` does not exist as a variable, thus attempting to access i
24342434
const { name: myName } = { name: 'Lydia' };
24352435

24362436
console.log(myName); // "lydia"
2437-
console.log(name); // ""
2437+
console.log(name); // "" ----- Browser e.g. Chrome
2438+
console.log(name); // ReferenceError: name is not defined ----- NodeJS
2439+
24382440
```
24392441

2440-
`name` is a global scope property, so when javascript is unable to find the name as a local variable, it looks at the _outer scopes_, which in this case is **window/global**, so it can be accessed via `window.name`.
2442+
`name` is a global scope property in the `browser`, so when javascript is unable to find the name as a local variable, it looks at the _outer scopes_, which in this case is **window**, so it can be accessed via `window.name`. But, in `NodeJS`, there is no such property on the `global` object, thus attempting to access a non-existent variable will raise a `ReferenceError`.
24412443

24422444
</p>
24432445
</details>

0 commit comments

Comments
 (0)