1. 使用 class 定义类
- 类声明
- 表达式声明
// 类声明
class Person {
}
// 表达式声明也是可以的,不过不建议在开发中使用
var Student = class {
}
2. 类的特性
class Person {}
var p = new Person()
console.log(Person) // [class Person]
console.log(Person.prototype) // {}
console.log(Person.prototype.constructor) // [class Person]
console.log(p.__proto__ === Person.prototype) // true
console.log(typeof Person) // function