/** * 工厂模式 */ class car { constructor(name) { this.name = name } run() { console.log(this.name + "在跑") } } class createCar { create(name) { return new car(name) } } let bmw = new createCar().create("bmw") bmw.run() let ford = new createCar().create("Ford") ford.run()