Skip to content

Instantly share code, notes, and snippets.

@snippe
Created November 9, 2014 01:32
Show Gist options
  • Save snippe/1dc5b21837c36702127d to your computer and use it in GitHub Desktop.
Save snippe/1dc5b21837c36702127d to your computer and use it in GitHub Desktop.
var first_object = {
a: 2,
b: 4
};
function adder(val1, val2) {
return this.a + this.b + val1 + val2;
}
Function.prototype.bind = function (obj) {
var method = this,
temp = function () {
return method.apply(obj, arguments);
};
return temp;
}
var first = adder.bind(first_object);
console.log(first(5, 6));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment