Constructor
Definition
A special method inside a class that is called when a new instance is created with the `new` keyword. It initializes the object's properties and sets up its initial state.
Code Example
Learn More
Related Terms
Every JavaScript object has a hidden internal property called [[Prototype]] that links to another object. When a property is accessed on an object and not found, JavaScript walks up the prototype chain to find it. This is the basis of JavaScript's inheritance model.
ClassES6 syntactic sugar over JavaScript's prototype-based inheritance. Classes provide a cleaner way to create objects and implement inheritance using extends and super.
This KeywordA special keyword that refers to the object a function is called on. Its value depends on how a function is invoked: in a method, this refers to the owner object; in a regular function, it defaults to globalThis (or undefined in strict mode).