Fixed incorrect it's/its
This commit is contained in:
parent
c693192018
commit
c8df40f4fa
1 changed files with 3 additions and 3 deletions
|
@ -9,7 +9,7 @@ In contrast, objects are used to store keyed collections of various data and mor
|
||||||
|
|
||||||
An object can be created with figure brackets `{…}` with an optional list of *properties*. A property is a "key: value" pair, where `key` is a string (also called a "property name"), and `value` can be anything.
|
An object can be created with figure brackets `{…}` with an optional list of *properties*. A property is a "key: value" pair, where `key` is a string (also called a "property name"), and `value` can be anything.
|
||||||
|
|
||||||
We can imagine an object as a cabinet with signed files. Every piece of data is stored in it's file by the key. It's easy to find a file by it's name or add/remove a file.
|
We can imagine an object as a cabinet with signed files. Every piece of data is stored in its file by the key. It's easy to find a file by its name or add/remove a file.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
@ -472,7 +472,7 @@ As a result we have two independent variables, each one is storing the string `"
|
||||||
|
|
||||||
Objects are not like that.
|
Objects are not like that.
|
||||||
|
|
||||||
**A variable stores not the object itself, but it's "address in memory", in other words "a reference" to it.**
|
**A variable stores not the object itself, but its "address in memory", in other words "a reference" to it.**
|
||||||
|
|
||||||
Here's the picture for the object:
|
Here's the picture for the object:
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ user.sizes.width++; // change a property from one place
|
||||||
alert(clone.sizes.width); // 51, see the result from the other one
|
alert(clone.sizes.width); // 51, see the result from the other one
|
||||||
```
|
```
|
||||||
|
|
||||||
To fix that, we should use the cloning loop that examines each value of `user[key]` and, if it's an object, then replicate it's structure as well. That is called a "deep cloning".
|
To fix that, we should use the cloning loop that examines each value of `user[key]` and, if it's an object, then replicate its structure as well. That is called a "deep cloning".
|
||||||
|
|
||||||
There's a standard algorithm for deep cloning that handles the case above and more complex cases, called the [Structured cloning algorithm](https://w3c.github.io/html/infrastructure.html#internal-structured-cloning-algorithm). In order not to reinvent the wheel, we can use a working implementation of it from the JavaScript library [lodash](https://lodash.com), the method is called [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep).
|
There's a standard algorithm for deep cloning that handles the case above and more complex cases, called the [Structured cloning algorithm](https://w3c.github.io/html/infrastructure.html#internal-structured-cloning-algorithm). In order not to reinvent the wheel, we can use a working implementation of it from the JavaScript library [lodash](https://lodash.com), the method is called [_.cloneDeep(obj)](https://lodash.com/docs#cloneDeep).
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue