extending built-in classes

☢️ Alert

Normally, when one class extends another, both static and non-static methods are inherited. ( 👉 JS.info ⟩ Static properties and methods )

But built-in classes are an exception. They don’t inherit statics from each other.❗️❗️❗️

比較 class B extends A 與 Date extends Object 的不同:

  • 一般的 class A, B,它們之間 prototype 的連結,所以 A 所有的 static properties B 也都有。

  • 但 Date 與 Object 之間並沒有連結,因此雖然有 Object.keys() 方法,但卻沒有 Date.keys() 方法❗️

Last updated