Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
The class declaration creates a binding of a new class to a given name.
You can also define classes using the class expression.
The class body of a class declaration is executed in strict mode. The class declaration is very similar to let:
Outside the class body, class declarations can be re-assigned like let, but you should avoid doing so. Within the class body, the binding is constant like const.
In the following example, we first define a class named Rectangle, then extend it to create a class named FilledRectangle.
Note that super(), used in the constructor, can only be used in constructors, and must be called before the this keyword can be used.
| ECMAScript® 2027 Language Specification # sec-class-definitions |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 8, 2025 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.