JavaScript Object.setPrototypeOf() MethodThe Object.setPrototypeOf() method sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null. All JavaScript objects inherit properties and methods from a prototype. It is generally considered the proper way to set the prototype of an object. Syntax:Parameters:obj: It is the object which is to have its prototype set. Prototype: It is the object's new prototype (an object or null). Return value:This method returns the specified object. Browser Support:
Example 1Output: [object Object] { drive: drive() { return 'Add raay'; }, net: net() { return 'use net'; } } "use net" "Add raay" Example 2Output: "people makes" Example 3Output: [object Object] { drive: drive() { return 'driving toyota'; }, wifi: wifi() { return 'carry'; } } "carry" Next TopicJavaScript Objects |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India