docs: add output comment in Symbols article
This commit is contained in:
parent
30a5d5e2a7
commit
f569591c07
1 changed files with 1 additions and 1 deletions
|
@ -169,7 +169,7 @@ for (let key in user) alert(key); // name, age (no symbols)
|
|||
*/!*
|
||||
|
||||
// the direct access by the symbol works
|
||||
alert( "Direct: " + user[id] );
|
||||
alert( "Direct: " + user[id] ); // Direct: 123
|
||||
```
|
||||
|
||||
[Object.keys(user)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) also ignores them. That's a part of the general "hiding symbolic properties" principle. If another script or a library loops over our object, it won't unexpectedly access a symbolic property.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue