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
1. The references can't go in circles. JavaScript will throw an error if we try to assign `__proto__` in a circle.
137
-
2. The value of `__proto__` can be either an object or `null`, other types (like primitives) are ignored.
136
+
2. The value of `__proto__` can be either an object or `null`. Other types are ignored.
138
137
139
138
Also it may be obvious, but still: there can be only one `[[Prototype]]`. An object may not inherit from two others.
140
139
@@ -171,7 +170,7 @@ From now on, `rabbit.walk()` call finds the method immediately in the object and
171
170
172
171

173
172
174
-
That's for data properties only, not for accessors. If a property is a getter/setter, then it behaves like a function: getters/setters are looked up in the prototype.
173
+
Accessor properties are an exception, as assignment is handled by a setter function. So writing to such a property is actually the same as calling a function.
175
174
176
175
For that reason `admin.fullName` works correctly in the code below:
177
176
@@ -247,7 +246,7 @@ The resulting picture:
247
246
248
247

249
248
250
-
If we had other objects like `bird`, `snake` etc inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects.
249
+
If we had other objects like `bird`, `snake` etc inheriting from `animal`, they would also gain access to methods of `animal`. But `this` in each method call would be the corresponding object, evaluated at the call-time (before dot), not `animal`. So when we write data into `this`, it is stored into these objects.
251
250
252
251
As a result, methods are shared, but the object state is not.
253
252
@@ -313,8 +312,8 @@ Note, there's one funny thing. Where is the method `rabbit.hasOwnProperty` comin
313
312
314
313
The answer is simple: it's not enumerable. Just like all other properties of `Object.prototype`, it has `enumerable:false` flag. That's why they are not listed.
315
314
316
-
```smart header="All other iteration methods ignore inherited properties"
317
-
All other key/value-getting methods, such as `Object.keys`, `Object.values` and so on ignore inherited properties.
315
+
```smart header="Almost all other key/value-getting methods ignore inherited properties"
316
+
Almost all other key/value-getting methods, such as `Object.keys`, `Object.values` and so on ignore inherited properties.
318
317
319
318
They only operate on the object itself. Properties from the prototype are taken into account.
0 commit comments