声明和初始化

接口(JS 中不存在)

// 示例中使用类, 
// 因为 JS 中没有接口
class Printable {
    constructor() {
        throw new Error("Can't instantiate abstract class!");
    }

    print(color) {
        throw new Error("Abstract method!");
    }
}

let shape = new Printable(); //<- Error

console.log(shape);