Javascript - Function Arguments to Array

function arbitraryOnlyArgs() { console.log(, arguments); var args =; console.log(, args); } function mixedArgs(a, b) { console.log(, arguments); var args =, 2); console.log(, args); }
If you need to manipulate/handle extra arguments in you functions (eg. sort or walk them), just "slice" them to get all the Array.prototype power.

These examples show how to convert arbitrary Arguments into Arrays.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.