Junior JavaScript

What is the constructor method?

The constructor is a special method for initializing new objects created from a class.

Example:

class Car {

constructor(brand, model) {

this.brand = brand;

this.model = model;

More from JavaScript Tutorial

All questions for this course