MCPcopy Create free account
hub / github.com/OBKoro1/web-basics / myCreate

Function myCreate

src/js/Object.create/Object.create.js:2–6  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

1// 将传入的对象作为新对象原型
2function myCreate(obj) {
3 function F() {}
4 F.prototype = obj
5 return new F()
6}
7const obj1 = { p: 1 }
8const obj2 = Object.create(obj1)
9obj1.p = 2

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected