minor
This commit is contained in:
parent
d1cf45eda8
commit
d32eabef0f
2 changed files with 6 additions and 4 deletions
|
@ -271,7 +271,7 @@ So, we can set many properties at once.
|
|||
|
||||
## Object.getOwnPropertyDescriptors
|
||||
|
||||
To get many descriptors at once, we can use the method [Object.getOwnPropertyDescriptors(obj)](mdn:js/Object/getOwnPropertyDescriptors).
|
||||
To get all property descriptors at once, we can use the method [Object.getOwnPropertyDescriptors(obj)](mdn:js/Object/getOwnPropertyDescriptors).
|
||||
|
||||
Together with `Object.defineProperties` it can be used as a "flags-aware" way of cloning an object:
|
||||
|
||||
|
@ -289,6 +289,8 @@ for(let key in user) {
|
|||
|
||||
...But that does not copy flags. So if we want a "better" clone then `Object.defineProperties` is preferred.
|
||||
|
||||
Another difference is that `for..in` ignores symbolic properties, but `Object.getOwnPropertyDescriptors` returns *all* property descriptors including symbolic ones.
|
||||
|
||||
## Sealing an object globally
|
||||
|
||||
Property descriptors work at the level of individual properties.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue