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
Built-in classes like Array, Map and others are extendable also.
4
+
Array、Mapなどの組み込みのクラスも拡張可能です。
5
5
6
-
For instance, here `PowerArray`inherits from the native `Array`:
6
+
例えば、ここでは `PowerArray`はネイティブの `Array` を継承しています:
7
7
8
8
```js run
9
-
//add one more method to it (can do more)
9
+
//1つメソッドを追加しています(その他のことももちろん可能です)
10
10
classPowerArrayextendsArray {
11
11
isEmpty() {
12
12
returnthis.length===0;
@@ -21,21 +21,22 @@ alert(filteredArr); // 10, 50
21
21
alert(filteredArr.isEmpty()); // false
22
22
```
23
23
24
-
Please note a very interesting thing. Built-in methods like `filter`, `map` and others -- return new objects of exactly the inherited type. They rely on the `constructor` property to do so.
But statics are an exception. Built-in classes don't inherit static properties from each other.
75
+
しかし、静的は例外です。組み込みのクラスはお互いから静的なプロパティを継承しません。
75
76
76
-
In other words, the prototype of build-in constructor `Array`does not point to `Object`. This way `Array`and`Date`do not have `Array.keys` or`Date.keys`. And that feels natural.
Here's the picture structure for `Date`and`Object`:
79
+
これは、`Date`と`Object` の構造のイメージです:
79
80
80
81

81
82
82
-
Note, there's no link between `Date`and`Object`. Both `Object`and`Date`exist independently. `Date.prototype`inherits from `Object.prototype`, but that's all.
0 commit comments