Object.createbeginner// 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.create(proto) creates a new object whose prototype is set to proto. This is a way to set up prototype-based inheritance without using classes.
Challenge: Implement createWithProto(proto) that returns a new object with proto as its prototype.
const animal = { speak() { return 'sound' } }
const dog = createWithProto(animal)
Object.getPrototypeOf(dog) === animal // β true