JavaScript Inheritance Done Right  by jonpress  One of the worst
(and possibly also one of the best) things about JavaScript is
that it offers you many ways to do anything. Some tricks are
simple and neat while others can be complex and confusing.  If
you have done some research, you will likely have come across
many ways of implementing inheritance in JavaScript. I have
personally used a lot of variations over time in various
projects but it’s not until recently that I have settled on a
particular technique.  I have chosen this particular technique
because I feel that it most closely resembles how most OO
programming languages implement inheritance. To get it to work
properly, you should use the prototype-based method of class
definition. Here is an example of the technique in action:
function BaseClass(name) { = name; } = function (arg) {
    return ‘This is the foo method with argument: ‘ + arg;
function SubClass(name) {     // Call the base class’
constructor., name);  // SubClass’ prototype is based on