- 简单示例
class Circle {
constructor (radius) {
this.radius = radius
this.move = function() {}
}
draw() {
console.log('draw')
}
}
const c = new Circle(1)
class本质是function,_classCallCheck用来确保使用了new
- 函数和表达式的区别
函数声明是置顶的,表达式不会置顶
sayHello()
sayHi()
function sayHello() {
console.log('Hello')
}
const sayHi = function(){
console.log('Hi')
}
类表达式和类声明都不会置顶,
const c = new Circle()
class Circle {
}
const Square = class {}