Classes

JavaScript Classes are templates for JavaScript Objects.

Use the keyword class to create a class.

Always add a method named constructor():

class Car 
{  
	constructor(name, year) 
	{  
		this.name \= name;  
		this.year \= year;  
	}  
}

A JavaScript class is not an object.

It is a template for JavaScript objects.

let myCar1 = new Car("Ford", 2014);  
let myCar2 = new Car("Audi", 2019);

Backlinks