Added reference link to mdn docs for Object.keys(user)

This commit is contained in:
akxavier 2021-12-06 18:46:14 +05:30
parent a829155758
commit 762d0e5da3

View file

@ -161,7 +161,7 @@ for (let key in user) alert(key); // name, age (no symbols)
alert( "Direct: " + user[id] );
```
`Object.keys(user)` 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.
[Object.keys(user)](mdn:js/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.
In contrast, [Object.assign](mdn:js/Object/assign) copies both string and symbol properties: