Skip to content

Commit d32eabe

Browse files
committed
minor
1 parent d1cf45e commit d32eabe

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

1-js/07-object-oriented-programming/01-property-descriptors/article.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ So, we can set many properties at once.
271271

272272
## Object.getOwnPropertyDescriptors
273273

274-
To get many descriptors at once, we can use the method [Object.getOwnPropertyDescriptors(obj)](mdn:js/Object/getOwnPropertyDescriptors).
274+
To get all property descriptors at once, we can use the method [Object.getOwnPropertyDescriptors(obj)](mdn:js/Object/getOwnPropertyDescriptors).
275275

276276
Together with `Object.defineProperties` it can be used as a "flags-aware" way of cloning an object:
277277

@@ -289,6 +289,8 @@ for(let key in user) {
289289

290290
...But that does not copy flags. So if we want a "better" clone then `Object.defineProperties` is preferred.
291291

292+
Another difference is that `for..in` ignores symbolic properties, but `Object.getOwnPropertyDescriptors` returns *all* property descriptors including symbolic ones.
293+
292294
## Sealing an object globally
293295

294296
Property descriptors work at the level of individual properties.

1-js/07-object-oriented-programming/06-prototype-methods/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ alert(rabbit.jumps); // true
5151

5252
The descriptors are in the same format as described in the chapter <info:property-descriptors>.
5353

54-
We can use `Object.create` to perform a full object cloning, like this:
54+
We can use `Object.create` to perform an object cloning more powerful than copying properties in `for..in`:
5555

5656
```js
5757
// fully identical shallow clone of obj
58-
let clone = Object.create(obj, Object.getOwnPropertyDescriptors(obj));
58+
let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
5959
```
6060

61-
This call makes a truly exact copy of `obj`, including all properties: enumerable and non-enumerable, data properties and setters/getters -- everything, and with the right `[[Prototype]]`. But not an in-depth copy of course.
61+
This call makes a truly exact copy of `obj`, including all properties: enumerable and non-enumerable, data properties and setters/getters -- everything, and with the right `[[Prototype]]`.
6262

6363
## Brief history
6464

0 commit comments

Comments
 (0)