Get to know MDN better
此頁面由社群從英文翻譯而來。了解更多並加入 MDN Web Docs 社群。
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2016年3月.
extends 關鍵字被使用於類別(class)宣告或類別(class)表達式中來建立擴展的子類別 。
extends 關鍵字可用於建立一個自訂類別或內建類別的子類別。
其繼承之原型 .prototype 必須是 Object 或 null。
第一個範例是根據 Polygon類別建立一個名為 Square 的子類別。此範例提取自線上示例。
這個範例擴展了內建的 Date 類別。此範例提取自線上範例。
像擴展普通類別一樣擴展 null,但新對象的原型不會繼承 Object.prototype。
| ECMAScript® 2027 Language Specification # sec-class-definitions |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年7月16日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.