prototype based vs. class based inheritance

In JavaScript, every object is at the same time an instance and a class. To do inheritance, you can use any object instance as a prototype.

In Python, C++, etc.. there are classes, and instances, as separate concepts. In order to do inheritance, you have to use the base class to create a new class, which can then be used to produce derived instances.

Why did JavaScript go in this direction (prototype-based object orientation)? what are the advantages (and disadvantages) of prototype-based OO with respect to traditional, class-based OO?

3 Answers
3

Leave a Comment