JavaScript Inheritance

JavaScript objects can inherit from others using the Object.create() function as follow:

function A()
{
    // some initialization
}

A.prototype = {
    var_name: "some value",

    func_name: function()
    {
        // some implementation
    }
};

function B()
{
    // some initialization
}

// make B inherit from A
B.prototype = Object.create(A);

Unfortunately, that prevents you from using the object declaration to extend B. Now you have to use B.prototype.name = value or function.