Object.setPrototypeOfintermediate// Set the prototype of an object
const animal = { breathe() { return true } }
const dog = {}
Object.setPrototypeOf(dog, animal)
dog.breathe() // β trueUse Object.setPrototypeOf() to dynamically change an object's prototype, though creating objects with the correct prototype upfront is preferred.
Setting the prototype to null creates an object with no prototype chain β similar to Object.create(null). Such objects have no inherited methods.
Challenge: Set an object's prototype to null and verify it loses inherited methods.