JS Coding Questions Logo
JS Coding Questions
#261💼 Interview💻 Code

How do you set the prototype of one object to another

Advertisement

728x90

You can use the Object.setPrototypeOf() method that sets the prototype (i.e., the internal Prototype property) of a specified object to another object or null. For example, if you want to set prototype of a square object to rectangle object would be as follows,

javascript
1Object.setPrototypeOf(Square.prototype, Rectangle.prototype);
2
3Object.setPrototypeOf({}, null);

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 4

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
261of476
How do you set the prototype of one object to another | JSCodingQuestions.com