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月.
class キーワードを使用すると、式内でクラスを定義することができます。
クラスは、 class 宣言 を使用して定義することもできます。
class 式は、class 宣言とよく似ており、構文もほぼ同じです。 class 宣言と同様に、 class 式の本体は厳格モードで実行されます。 class 式と class 宣言の主な違いは、クラス名です。 class 式ではこのクラス名を省略できるため、無名クラスを作成することができます。クラス式はクラスを再定義できますが、 class 宣言を使用してクラスを再宣言すると、 SyntaxError が発生します。詳細については、クラスの章を参照してください。
以下は、名前のない簡単なクラス式です。変数 Foo を使って参照できます。
クラス内部で現在のクラスを参照したい場合は、名前付きクラス式を作成してください。この名前は、そのクラス式自身のスコープ内だけで見ることができます。
| ECMAScript® 2027 Language Specification # sec-class-definitions |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年8月31日 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.