Object.create()的实现

351 阅读1分钟
function createObject(o) {
    // 创建临时中间类
    function F() {
        
    }
    // 修改类的原型为o, 于是f的实例都将继承o上的方法
    F.prototype = o;
    return new F();
}

原来如此