72.实现object.create
Opened this issue · 0 comments
webVueBlog commented
function createObj(o) {
function f() {};
f.prototype = o;
return new f;
}
function _create(proto, propertiesObject) {
if (typeof proto !== 'object' && proto !== null) throw new TYpeError("")
function Fn() {}
Fn.prototype = proto
const obj = new Fn()
if (propertiesObject) Object.defineProperties(obj, propertiesObject);
if (proto === null) {
Object.getPrototypeOf(obj) = null;
}
return obj;
}