Skip to content

Instantly share code, notes, and snippets.

@guisouza
Created July 29, 2014 20:23

Revisions

  1. guisouza created this gist Jul 29, 2014.
    19 changes: 19 additions & 0 deletions bind() Polyfill.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    if (!Function.prototype.bind) {
    Function.prototype.bind = function (oThis) {

    var aArgs = Array.prototype.slice.call(arguments, 1),
    fToBind = this,
    fNOP = function () {},
    fBound = function () {
    return fToBind.apply(this instanceof fNOP && oThis
    ? this
    : oThis,
    aArgs.concat(Array.prototype.slice.call(arguments)));
    };

    fNOP.prototype = this.prototype;
    fBound.prototype = new fNOP();

    return fBound;
    };
    }