SOURCE

class People{
    say1(){console.log(1)}
}

class Dog{
    say2(){console.log(2)}
}

class Singer{
    say3(){console.log(3)}
}

class Luck extends mixin(People, Dog, Singer) {
    hello(){console.log(4)}
}

// 注意:原型上的属性是不可枚举的,可用Reflect.ownKeys获取
function mixin(...func) {
    let obj = {};
    func.map(item => {
        Reflect.ownKeys(item.prototype).forEach(sub => {
          if (sub !== 'constructor') {
                obj[sub] = item.prototype[sub]
            }  
        })
    })
    let fn = function(){}
    fn.prototype = obj
    fn.prototype.constructor = fn
    console.log(fn.prototype)
    return fn
}

let me = new Luck();
console.log(me)
me.say1()
me.say2()
me.say3()
me.hello()
console 命令行工具 X clear

                    
>
console