constructor()
constructor() is a JavaScript method in the Class category. Creates class instances. The syntax is constructor(params). A typical example: class Foo { constructor(x) { this.x = x } }. A close sibling is class, which defines a class. A close sibling is extends, which inherits from another class. A close sibling is super(), which calls parent constructor. A close sibling is static, which defines a static method. More about this category: Class syntax. Related Class methods: class, extends, super(), static, new.target. This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls. You can try constructor() immediately in the JavaScript playground, look up unfamiliar terms in the glossary, or return to the JS Reference homepage.