create
# 手写实现Object.create
// 思路:将传入的对象作为原型
function create(obj) {
if (typeof proto !== 'object' || proto === null) throw new Error('');
const obj = {};
obj.__proto__ = proto;
return obj;
}
1
2
3
4
5
6
7
2
3
4
5
6
7
更新时间: 3/15/2022, 12:28:01 AM