As I can see in the question ‘How does JavaScript .prototype work?’ the correct way to use the prototype property is with a functional object. But I am not able to understand why we need a functional object to use prototype?
As I can see in the question ‘How does JavaScript .prototype work?’ the correct
Share
When you create a function in JavaScript, the interpreter automatically creates a prototype object for it. This is because functions can be used as constructors.
Only functions and no other object can be used as a constructor.
That’s the reason only functions have a
prototypeproperty. Theprototypeproperty of a function is very special. Instances of that function will have the prototype of the function in their__proto__chain.Read this answer for more details: https://stackoverflow.com/a/8096017/783743