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

What is the difference between proto and prototype

Advertisement

728x90

The __proto__ object is the actual object that is used in the lookup chain to resolve methods, etc. Whereas prototype is the object that is used to build __proto__ when you create an object with the new operator (a special variant of a function call).

javascript
1new Employee().__proto__ === Employee.prototype;
2
3new Employee().prototype === undefined;

There are few more differences,

| feature | Prototype | proto |

| ---------- | ------------------------------------------------------------ | ---------------------------------------------------------- |

| Access | All function constructors have prototype properties. | All objects have \_\_proto\_\_ property |

| Purpose | Used to reduce memory wastage with a single copy of function | Used in lookup chain to resolve methods, constructors etc. |

| ECMAScript | Introduced in ES6 | Introduced in ES5 |

| Usage | Frequently used | Rarely used |

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 6

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
177of476