You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/04-object-basics/01-object/article.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ In contrast, objects are used to store keyed collections of various data and mor
9
9
10
10
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.
11
11
12
-
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.
12
+
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.
13
13
14
14

15
15
@@ -472,7 +472,7 @@ As a result we have two independent variables, each one is storing the string `"
472
472
473
473
Objects are not like that.
474
474
475
-
**A variable stores not the object itself, but it's "address in memory", in other words "a reference" to it.**
475
+
**A variable stores not the object itself, but its "address in memory", in other words "a reference" to it.**
476
476
477
477
Here's the picture for the object:
478
478
@@ -703,7 +703,7 @@ user.sizes.width++; // change a property from one place
703
703
alert(clone.sizes.width); // 51, see the result from the other one
704
704
```
705
705
706
-
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".
706
+
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".
707
707
708
708
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).
0 commit comments