Skip to content

Instantly share code, notes, and snippets.

@lgmkr
Forked from ValeriiVasin/gist:1548808
Created August 21, 2012 12:50

Revisions

  1. Valeriy Vasin created this gist Jan 2, 2012.
    22 changes: 22 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    var inherit = (function () {
    var F = function () {};
    return function (C, P) {
    F.prototype = P.prototype;
    C.prototype = new F();
    C.uber = P.prototype;
    C.prototype.constructor = C;
    };
    }());

    // usage
    var Parent = function () {};
    Parent.prototype.say = function () {
    console.log('hello');
    };

    var Child = function () {};

    inherit(Child, Parent);

    var obj = new Child();
    obj.say();