Skip to content

Instantly share code, notes, and snippets.

View josherich's full-sized avatar

Huifeng Chen josherich

View GitHub Profile
@josherich
josherich / bind.js
Last active January 4, 2016 03:09
Functional Javascript
bind = function(oThis) {
if (typeof this !== "function") {
throw new TypeError("Function.prototype.bind is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function() {},
fBound = function() {
return fToBind.apply(this instanceof fNOP && oThis
? this