Last updated 3 years ago
Was this helpful?
ES6 引入了 class 语法,提供了关于类构造、继承、静态成员的语法糖。
// define a class class Car { // constructor method constructor(name, year) { this.name = name; this.year = year; } // other methods run() { // ... } } // create new instance let myCar1 = new Car("Ford", 2014);
[1] https://www.w3schools.com/js/js_class_intro.asp