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

How do you get the prototype of an object

Advertisement

728x90

You can use the Object.getPrototypeOf(obj) method to return the prototype of the specified object. i.e. The value of the internal prototype property. If there are no inherited properties then null value is returned.

javascript
1const newPrototype = {};
2
3const newObject = Object.create(newPrototype);
4
5console.log(Object.getPrototypeOf(newObject) === newPrototype); // true

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 2

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
259of476