docs.rodeo

MDN Web Docs mirror

Constructor

{{GlossarySidebar}} 

A constructor is a specialized {{glossary("function")}}  that generates {{glossary("object", "objects")}}  with the same shape and behavior. The constructor initializes this object with some data specific to the object. The concept of a constructor can be applied to most {{glossary("OOP","object-oriented programming")}}  languages.

In {{glossary("JavaScript")}} , a constructor is usually declared within a class, but it can also be declared as a function. In fact, any function that can be called with the new operator is a constructor.

See also

In this article

View on MDN