模拟Object.create

# 模拟Object.create

Object.create()方法创建一个新对象,使用现有的对象来提供新创建的对象的 __proto__

// 模拟 Object.create

function create(proto) {
 function F() {}
 F.prototype = proto;

 return new F();
}
1
2
3
4
5
6
7
8
上次更新: 2022/7/1 下午5:57:34