Skip to content

Commit df58d3f

Browse files
authored
Merge pull request #1513 from hrodward/patch-31
Update article.md
2 parents 71fb491 + 028b408 commit df58d3f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

1-js/09-classes/06-instanceof/article.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The `instanceof` operator allows to check whether an object belongs to a certain class. It also takes inheritance into account.
44

5-
Such a check may be necessary in many cases, here we'll use it for building a *polymorphic* function, the one that treats arguments differently depending on their type.
5+
Such a check may be necessary in many cases. Here we'll use it for building a *polymorphic* function, the one that treats arguments differently depending on their type.
66

77
## The instanceof operator [#ref-instanceof]
88

@@ -46,7 +46,7 @@ alert( arr instanceof Object ); // true
4646

4747
Please note that `arr` also belongs to the `Object` class. That's because `Array` prototypically inherits from `Object`.
4848

49-
Normally, `instanceof` operator examines the prototype chain for the check. We can also set a custom logic in the static method `Symbol.hasInstance`.
49+
Normally, `instanceof` examines the prototype chain for the check. We can also set a custom logic in the static method `Symbol.hasInstance`.
5050

5151
The algorithm of `obj instanceof Class` works roughly as follows:
5252

@@ -68,7 +68,7 @@ The algorithm of `obj instanceof Class` works roughly as follows:
6868
alert(obj instanceof Animal); // true: Animal[Symbol.hasInstance](obj) is called
6969
```
7070

71-
2. Most classes do not have `Symbol.hasInstance`. In that case, the standard logic is used: `obj instanceOf Class` checks whether `Class.prototype` equals to one of prototypes in the `obj` prototype chain.
71+
2. Most classes do not have `Symbol.hasInstance`. In that case, the standard logic is used: `obj instanceOf Class` checks whether `Class.prototype` is equal to one of the prototypes in the `obj` prototype chain.
7272

7373
In other words, compare one after another:
7474
```js
@@ -107,7 +107,7 @@ By the way, there's also a method [objA.isPrototypeOf(objB)](mdn:js/object/isPro
107107

108108
It's funny, but the `Class` constructor itself does not participate in the check! Only the chain of prototypes and `Class.prototype` matters.
109109
110-
That can lead to interesting consequences when `prototype` property is changed after the object is created.
110+
That can lead to interesting consequences when a `prototype` property is changed after the object is created.
111111
112112
Like here:
113113
@@ -186,7 +186,7 @@ let user = {
186186
alert( {}.toString.call(user) ); // [object User]
187187
```
188188
189-
For most environment-specific objects, there is such a property. Here are few browser specific examples:
189+
For most environment-specific objects, there is such a property. Here are some browser specific examples:
190190
191191
```js run
192192
// toStringTag for the environment-specific object and class:

0 commit comments

Comments
 (0)