Curriculum
Course: React
Login

Curriculum

React

Text lesson

ES6 Classes Example

Example

Instantiate an object named “mycar” from the Car class:

class Car {
 constructor(name) {
    this.brand = name;
 }
}
const mycar = new Car("Ford");
Note: The constructor function is automatically invoked when the object is created.