Skip to content

Instantly share code, notes, and snippets.

@yangsu
Created January 29, 2013 21:10
Show Gist options
  • Save yangsu/4667899 to your computer and use it in GitHub Desktop.
Save yangsu/4667899 to your computer and use it in GitHub Desktop.
JavaScript Function Invocation - Apply/Call
var incrementer = function (inc) {
inc = inc || 1;
this.value += inc;
};
var foo = { value: 5 };
incrementer.apply(foo, [1]); // foo.value = 6
incrementer.call(foo, 2); // foo.value = 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment