Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:16
Show Gist options
  • Save psiborg/1569643 to your computer and use it in GitHub Desktop.
Save psiborg/1569643 to your computer and use it in GitHub Desktop.
JS Context Bind 1
var myObject = {
someProperty: 42
};
function adder (num1, num2) {
return this.someProperty + num1 + num2;
}
console.log(adder.call(myObject, 10, 20)); // 72
console.log(adder.apply(myObject, [10, 20])); // 72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment