What keyword is used to create a class in JavaScript?

The story behind the answer

The JavaScript keyword used to create a class is class.

A class declaration provides a structured syntax for defining objects, including a constructor, methods, getters, setters, and—in modern JavaScript—private fields. For example, `class User { constructor(name) { this.name = name; } }` defines a class whose instances can be created with `new User("Ava")`.

JavaScript classes arrived with ECMAScript 2015, also known as ES6. Before that syntax existed, developers commonly built constructor functions and connected objects through the prototype property. The class syntax makes that style easier to read, but JavaScript remains prototype-based underneath: class methods are stored on the prototype, and inheritance uses `extends` and `super`.

The distractors describe related ideas, which makes them easy to confuse. `prototype` is an inheritance mechanism, `function` can define constructors or behavior, and `object` describes a value or data structure. None of those is the keyword that introduces a class declaration. JavaScript classes also differ from classes in some languages because class bodies are strict mode by default and cannot be called without `new`.

Source: Wikipedia · fact-checked Aug. 2026

Add question to a list

Choose a list to keep this question in: