Pseudoclassical vs. Prototypal: JavaScript allows both
There are two broad types of inheritance in programming: protoypal and classical. Prototypal just means that objects can inherit directly other objects, while classical involves objects being instances of classes, and subclasses inheriting from superclasses.
Pseudoclassical Inheritance
This type of object inheritance uses:
1. The 'constructor' function (to create objects)
2. The 'new' operator (to create objects)
3. The 'prototype' property (to build the inheritance chain)
Here, the pattern involves creating pseudoclasses using constructor functions, then using 'new' to create instances of the pseudoclass. The prototype property (inherited by all instances of the pseudoclass) contains the methods common to all instances of the pseudoclass.
Prototypal Inheritance
This type of object inheritance uses:
1. 'Object.create' (to create a new object)
2. A parameter object (the prototype for the new object)
As mentioned above, here we are creating new objects directly from existing ones, without any notion of classes.