diff --git a/1-js/07-object-oriented-programming/01-property-descriptors/article.md b/1-js/07-object-oriented-programming/01-property-descriptors/article.md index 33e8e52e..92d83365 100644 --- a/1-js/07-object-oriented-programming/01-property-descriptors/article.md +++ b/1-js/07-object-oriented-programming/01-property-descriptors/article.md @@ -68,7 +68,7 @@ Object.defineProperty(obj, propertyName, descriptor) `descriptor` : Property descriptor to apply. -If the property exist, it updates its flags, otherwise, it creates the property with the given value and flags. Please note, that if a flag is not supplied, it is assumed `false`. +If the property exists, `defineProperty` updates its flags. Otherwise, it creates the property with the given value and flags; in that case, if a flag is not supplied, it is assumed `false`. For instance, here a property `name` is created with all falsy flags: @@ -96,7 +96,7 @@ alert( JSON.stringify(descriptor, null, 2 ) ); */ ``` -Compare it with "normally created" user.name above: now all flags are falsy. If that's not what we want then we'd better to set them to `true` in the `descriptor`. +Compare it with "normally created" `user.name` above: now all flags are falsy. If that's not what we want then we'd better set them to `true` in `descriptor`. Now let's see effects of the flags by example. @@ -209,7 +209,7 @@ Math.PI = 3; // Error // delete Math.PI won't work either ``` -Making a property non-configurable is one-way road. We cannot change it back, because `defineProperty` doesn't work on non-configurable properties. +Making a property non-configurable is a one-way road. We cannot change it back, because `defineProperty` doesn't work on non-configurable properties. Here we are making `user.name` a "forever sealed" constant: @@ -266,7 +266,7 @@ So, we can set many properties at once. To get many descriptors at once, we can use the method [Object.getOwnPropertyDescriptors(obj)](mdn:js/Object/getOwnPropertyDescriptors). -Together with `Object.defineProperties` it can be used as an "flags-aware" way of cloning an object: +Together with `Object.defineProperties` it can be used as a "flags-aware" way of cloning an object: ```js let clone = Object.defineProperties({}, Object.getOwnPropertyDescriptors(obj)); diff --git a/1-js/07-object-oriented-programming/02-property-accessors/article.md b/1-js/07-object-oriented-programming/02-property-accessors/article.md index cdd9d9ea..a121886e 100644 --- a/1-js/07-object-oriented-programming/02-property-accessors/article.md +++ b/1-js/07-object-oriented-programming/02-property-accessors/article.md @@ -55,7 +55,7 @@ alert(user.fullName); // John Smith */!* ``` -From outside, an accessor property looks like a regular one. That's the idea of accessor properties. We don't call `user.fullName` as a function, we read it normally: the getter runs behind the scenes. +From outside, an accessor property looks like a regular one. That's the idea of accessor properties. We don't **call** `user.fullName` as a function, we **read** it normally: the getter runs behind the scenes. As of now, `fullName` has only a getter. If we attempt to assign `user.fullName=`, there will be an error. @@ -97,7 +97,7 @@ Sometimes it's normal that there's only a setter or only a getter. But the prope ## Accessor descriptors -Descriptors for accessor properties are different. +Descriptors for accessor properties are different - as compared with data properties. For accessor properties, there is no `value` and `writable`, but instead there are `get` and `set` functions. @@ -182,7 +182,7 @@ Technically, the external code may still access the name directly by using `user ## Using for compatibility -One of great ideas behind getters and setters -- they allow to take control over a "normal" data property and tweak it at any moment. +One of the great ideas behind getters and setters -- they allow to take control over a "normal" data property and tweak it at any moment. For instance, we started implementing user objects using data properties `name` and `age`: diff --git a/1-js/07-object-oriented-programming/03-prototype-inheritance/article.md b/1-js/07-object-oriented-programming/03-prototype-inheritance/article.md index 8af84740..40dff06b 100644 --- a/1-js/07-object-oriented-programming/03-prototype-inheritance/article.md +++ b/1-js/07-object-oriented-programming/03-prototype-inheritance/article.md @@ -159,7 +159,7 @@ rabbit.walk = function() { rabbit.walk(); // Rabbit! Bounce-bounce! ``` -Since now, `rabbit.walk()` call finds the method immediately in the object and executes it, without using the prototype: +From now on, `rabbit.walk()` call finds the method immediately in the object and executes it, without using the prototype: ![](proto-animal-rabbit-walk-2.png) @@ -192,7 +192,7 @@ alert(admin.fullName); // John Smith (*) admin.fullName = "Alice Cooper"; // (**) ``` -Here in the line `(*)` the property `admin.fullName` has a getter in the prototype `user`, so it is called. And in the line `(**)` the property is has a setter in the prototype, so it is called. +Here in the line `(*)` the property `admin.fullName` has a getter in the prototype `user`, so it is called. And in the line `(**)` the property has a setter in the prototype, so it is called. ## The value of "this" diff --git a/1-js/07-object-oriented-programming/04-function-prototype/article.md b/1-js/07-object-oriented-programming/04-function-prototype/article.md index d66a22a7..27c67e32 100644 --- a/1-js/07-object-oriented-programming/04-function-prototype/article.md +++ b/1-js/07-object-oriented-programming/04-function-prototype/article.md @@ -14,7 +14,7 @@ As we know already, `new F()` creates a new object. But what we didn't use yet ` That property is used by the JavaScript itself to set `[[Prototype]]` for new objects. -**When a new object is created with `new F()`, the `[[Prototype]]` of it is set to `F.prototype`.** +**When a new object is created with `new F()`, the object's `[[Prototype]]` is set to `F.prototype`.** Please note that `F.prototype` here means a regular property named `"prototype"` on `F`. It sounds something similar to the term "prototype", but here we really mean a regular property with this name. diff --git a/1-js/07-object-oriented-programming/05-native-prototypes/article.md b/1-js/07-object-oriented-programming/05-native-prototypes/article.md index b7b508cc..949e2d57 100644 --- a/1-js/07-object-oriented-programming/05-native-prototypes/article.md +++ b/1-js/07-object-oriented-programming/05-native-prototypes/article.md @@ -169,7 +169,7 @@ function showArgs() { } ``` -That's more efficient, because evades creation of an extra array object `[]`. From the other side -- more letters to write it. +That's more efficient, because it avoids the creation of an extra array object `[]`. On the other hand, it is longer to write. ## Summary diff --git a/1-js/07-object-oriented-programming/06-prototype-methods/article.md b/1-js/07-object-oriented-programming/06-prototype-methods/article.md index d841de39..ec14fd48 100644 --- a/1-js/07-object-oriented-programming/06-prototype-methods/article.md +++ b/1-js/07-object-oriented-programming/06-prototype-methods/article.md @@ -1,7 +1,7 @@ # Methods for prototypes -In this chapter we cover additional methods to work with the prototype. +In this chapter we cover additional methods to work with a prototype. There are also other ways to get/set a prototype, besides those that we already know: