接口(JS 中不存在)

// Examples with classes are used, 
// since there are no interfaces in JS
class Printable {
    constructor() {
        throw new Error("Can't instantiate abstract class!");
    }

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

let shape = new Printable();

console.log(shape);