Problem, as an interviewer would state it:
"Implement Object.create from scratch — creating a new object with a specified prototype, correctly handling the special Object.create(null) case (an object with NO prototype at all), matching real native behavior exactly."
Examples:
const parent = { greet() { return "hi"; } };
const child = myObjectCreate(parent);
child.greet(); // "hi" -- inherited via the prototype chain
Clarifying questions expected:
- Does
Object.create(null)need to genuinely produce an object with NO prototype at all, not just an object linked toObject.prototype? - Does the optional second
propertiesObjectargument (matching realObject.defineProperties's own format) need to be supported? - What should happen if
protois neither a real object nornull?
Code / implementation expected: Yes — real, direct proof of correct prototype linking, AND real, direct proof that myObjectCreate(null) produces a genuinely null-prototype object, not one silently linked to Object.prototype.