I have read that Javascript’s inheritance is prototypal.What does it mean?How can an object defined by the programer inherit the properties of a predefined object such as window ?
For example I need the function eval() in my own class . How can it be achieved?
I have read that Javascript’s inheritance is prototypal.What does it mean?How can an object
Share
What do you want exactly echieve to?
Here is the simplest way (not the best) of prototype inheritance:
It means that
obj1inherits all properties ofobj2I’ve forgot the main thing: eval==evil;
UPDATE:
I’ve made mistakes in the code above. That is not inheritance. Here is updated code:
And that is inharitance. Now
objhas properties defined inObject2ConstructorandObject1Constructor– parent ‘class’.See CMS’s comment below. He is totally right.