From c8df40f4fa89fe2f969c50b27456476ef4ea6203 Mon Sep 17 00:00:00 2001 From: andrej-repisky <29707624+andrej-repisky@users.noreply.github.com> Date: Mon, 22 Jan 2018 12:16:56 +0100 Subject: [PATCH] Fixed incorrect it's/its --- 1-js/04-object-basics/01-object/article.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/04-object-basics/01-object/article.md b/1-js/04-object-basics/01-object/article.md index 260c2457..7eb400b9 100644 --- a/1-js/04-object-basics/01-object/article.md +++ b/1-js/04-object-basics/01-object/article.md @@ -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. -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. ![](object.png) @@ -472,7 +472,7 @@ As a result we have two independent variables, each one is storing the string `" 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: @@ -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 ``` -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).