Curriculum
Course: React
Login

Curriculum

React

Text lesson

ES6 Classes

Classes

ES6 introduced classes, which are a type of function defined using the class keyword instead of function, with properties assigned inside a constructor() method.

Example

A basic class constructor:

class Car {
 constructor(name) {
    this.brand = name;
 }
}
Note the capitalization of the class name; we’ve started “Car” with an uppercase letter. This is a standard convention for naming classes.

You can now create objects using the Car class: