Skip to content

Instantly share code, notes, and snippets.

@snippe
Created November 9, 2014 01:29
Show Gist options
  • Save snippe/3c68ab9a1331856917d4 to your computer and use it in GitHub Desktop.
Save snippe/3c68ab9a1331856917d4 to your computer and use it in GitHub Desktop.
var first_object = {
num: 4
};
function multi(mul) {
return this.num * mul;
}
Function.prototype.bind = function (obj) {
var method = this,
temp = function () {
return method.apply(obj, arguments);
};
return temp;
}
var first_mul = multi.bind(first_object);
console.log(first_mul(5)); //20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment