Skip to content

Instantly share code, notes, and snippets.

@kevin-miles
Last active December 28, 2015 14:39
Show Gist options
  • Save kevin-miles/7515995 to your computer and use it in GitHub Desktop.
Save kevin-miles/7515995 to your computer and use it in GitHub Desktop.
Javascript - Use array prototype slice to collect arguments of a function
//notice that there are no parameters defined, but arguments are still copied
function doSomething () {
var args = Array.prototype.slice.call (arguments);
console.log (args);
}
doSomething ("Water", "Salt", "Glue"); // ["Water", "Salt", "Glue"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment