I try demonstrate inheritance with immediately invokable function expression(IIFE) and prototype in the following code.
This sample code is written in different concepts you should read the following posts as well.
The following code demonstrate classic inheritance with JavaScript.
Same code as shown in the above, but I added a new function named inherit
in global Function.prototype
so that we don't need to write same code for inheritance. It looks like Employee.inherits(Person);
or Manager.inherits(Employee);
Notice that although Employee
and Manager
functions doesn't have inherits
function, it works due to global Function.prototype.inherits