Last active
December 28, 2015 14:39
-
-
Save kevin-miles/7515995 to your computer and use it in GitHub Desktop.
Javascript - Use array prototype slice to collect arguments of a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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