InterviewHubPRO
Section Overview
Q265

Question 265 of 521

Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

51%
JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)

How do you set the prototype of one object to another

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
  Object.setPrototypeOf(Square.prototype, Rectangle.prototype);
  Object.setPrototypeOf({}, null);