Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created August 23, 2010 17:20
Show Gist options
  • Save qoelet/545908 to your computer and use it in GitHub Desktop.
Save qoelet/545908 to your computer and use it in GitHub Desktop.
// consider this simple function
var calc_total = function(a,b,c) {
return (this + a + b + c);
}
calc_total.call(1,2,3,4,5); // result is 10. 1 is treated as this, and 2,3,4 as a,b,c. 5 is ignored.
var calc_total2 = function(a,b,c) {
return (this + a + b + c);
}
calc_total2.apply(1,[2,3,4,5]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment