implement your own Object.create
2022年5月1日小于 1 分钟
Object.create
implement your own Question
You can use Object.create() to create a new object.
Can you write your own myObjectCreate()
to do the same(well for the basic usage) ?
Note
- you don't need to support
propertiesObject
- 2nd parameter of Object.create - throw an Error if non-object is passed in. (why?)
Object.create()
andObject.setPrototypeOf()
should not be used.
Code
/**
* @param {any} proto
* @return {object}
*/
function myObjectCreate(proto) {
// your code here
}