Object.createintermediate// Create an object with a specific prototype
const proto = { greet() { return 'hi' } }
const child = Object.create(proto)
child.greet() // β 'hi'Use Object.create() to create a new object with a specific prototype, enabling prototype-based inheritance.
Object.getPrototypeOf(obj) returns the prototype set by Object.create, allowing you to confirm the prototype chain.
Challenge: Implement protoMatches(proto, obj) that returns whether Object.getPrototypeOf(obj) is strictly equal to proto.
const p = {}
const o = Object.create(p)
protoMatches(p, o) // β true