Merge pull request #2783 from akxavier/master

Added link for Object.keys(user)
This commit is contained in:
Ilya Kantor 2021-12-12 22:30:43 +03:00 committed by GitHub
commit 153fd11a85
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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