Skip to content

Instantly share code, notes, and snippets.

@ptzn
Created December 25, 2009 18:43
Show Gist options
  • Save ptzn/263714 to your computer and use it in GitHub Desktop.
Save ptzn/263714 to your computer and use it in GitHub Desktop.
example of the js apply method
function sum() {
var sum = 0;
for( var i =0; i sum += arguments[i];
}
return sum;
}
sum(1,2,3,4,5); // -> 15
var array = [1,2,3,4,5];
sum.apply(null, array); // -> 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment