Object.setPrototypeOf() JavaScript JS

The Javascript Object setPrototypeOf() method sets the prototype of a specified object to another object. Prototype can be another object or null.


Object.setPrototypeOf(object, prototype)

Parameters: object: It represents the object whose prototype has to be set. prototype: It represents the new prototype.

Return: Specified Object


<!DOCTYPE html>
let jewel = {
gems() {
return 'DIAMOND'; } }
let jewellery = {
stones() {
return 'PLATINUM'; } }
Object.setPrototypeOf(jewellery, jewel);
Please follow and like us:
Content Protection by DMCA.com