Skip to content

Instantly share code, notes, and snippets.

View kurtextrem's full-sized avatar

Jacob Groß kurtextrem

View GitHub Profile
@kurtextrem
kurtextrem / fast-bind.js
Created December 23, 2015 18:50 — forked from WebReflection/fast-bind.js
Function.prototype.bind is slow in JS, so we fix it plus we have great compatibility (at least for 90% of common cases without partial args)
+function(proto, Object) {
'use strict'
var originalBind = proto.bind
Object.defineProperty(proto, 'bind', {
value: function bind(context) {
var callback = this
return arguments.length === 1 ? function () { return callback.apply(context, arguments) } : originalBind.apply(callback, arguments)
}
})
}(Function.prototype, Object)