Skip to main content
InterviewHubPRO
Section Overview
Q265

Question 265 of 536

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

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

How do you set the prototype of one object to another

mid LevelMost AskedCode ExamplePrototypes

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);