JavaScript – Make a inheritance function

In JavaScript there are plenty of ways for inheritance. I can think of at least two. 🙂 However, a nice one is if you do everything “by the hand”. Thus, writing a function, that gets the inherited object and makes it a prototype of the new one. Thus, it works!

Pretty much in the demo, I have created four objects – v1, v2, v3, v4, each one inheriting the previous one. Then I am printing the properties of v3 and v4, to see what they have inherited.

output

Here comes the code:

Not a lot, eh? 🙂

About

VBA Developer