Function bind polyfill 发表于 2014-08-23 | | 阅读次数 A polyfill function for ES5 Function.prototype.bind: 123456789101112131415161718192021if (!Function.prototype.bind) { Function.prototype.bind = function (obj) { var slice = [].slice; var args = slice.call(arguments, 1); var self = this; var nop = function () {}; var bound = function () { return self.apply( this.instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)) ); nop.prototype = self.prototype; bound.prototype = new nop(); return bound; };}// fn.bind(obj}) => obj.bound => obj.bound(args)// Ctrl.bind(new Ctrl()) 本文作者: IIssNan 本文链接: http://notes.iissnan.com/2014/function-bind-polyfill/ 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 CN 许可协议。转载请注明出处!