Created
May 4, 2017 21:45
-
-
Save aaroneiche/98e74ab865e3d1ec6bf3498850d7c2f1 to your computer and use it in GitHub Desktop.
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
function myfunc(arg,arg2,arg3,arg4){ | |
console.log(arg); | |
console.log(arg2); | |
console.log(arg3); | |
console.log(arg4); | |
} | |
myfunc("test","test2","test3","test4"); //The typical way to do it. | |
args = ["test","test2","test3","test4"]; | |
myfunc(args); //You can't do this! | |
myfunc.apply(null,args); //You could do this | |
myfunc(...args); //but isn't this easier? | |
//====== | |
//Add some arrays: | |
var mid = ["song","that","never"]; | |
var lyrics = ["this","is","the",...mid,"ends"]; | |
console.log(...lyrics); | |
console.log(lyrics.join(" ")); | |
//console.log(...lyrics); | |
//====== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment