SOURCE

class Product {
    constructor(name) {
        this.name = name
    }
    init() {
        console.log('is init')
    }
    fun(){
        console.log('is fun')
    }
}

class Factory {
    create(name) {
        return new Product()
    }
}

let factory = new Factory()
let p = factory.create('p1')

p.init()
p.fun()
console 命令行工具 X clear

                    
>
console