Write Your JavaScript Code Here

// Object.setPrototypeOf() method sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null. // Object.setPrototypeOf(obj, prototype) let raay = { drive() { return 'Add raay'; } } let naty = { net() { return 'use net'; } } // Set raay's __proto__ to naty's __proto__'s __proto__ Object.setPrototypeOf(naty, raay); console.dir(naty); //prints the naty object console.log(naty.net()); // use net console.log(naty.drive()); // Add raay

Output: