html java script class create object code example
Example 1: how to create object in javascript with class
class Car {
constructor(name, year) {
this.name = name;
this.year = year;
}
}
Example 2: how to create object in javascript with class
let myCar1 = new Car("Ford", 2014);
let myCar2 = new Car("Audi", 2019);