News for hackers. Stuff that matters.
Re:The world's smallest and fastest classical JavaScript inh... by ivan_ah on Saturday February 15, 2014 @12:49PM (#7244525)
Cool, this is neat. Here is a fuller usage example:

    var Rectangle = augment(Object, {
        constructor: function (width, height) {
            this.height = height;
            this.width = width;
        },
        area: function () {
            return this.width * this.height;
        }
    });
    
    var Square = augment(Rectangle, {
        constructor: function (side) {
            Rectangle.call(this, side, side);
        }
    });
    
    sq = new Square(3)
    //augment.constructor {height: 3, width: 3, constructor: function, area: function}
    //    it will be a little annoying to see augment.constructor  in the console 
    
    sq.width
    // 3
    sq.area()
    // 9
    
    Square.prototype
    // Surrogate {constructor: function, area: function}
    Square.constructor
    // function Function() { [native code] }
    sq instanceof Rectangle
    //true

There are no comments on this comment yet.