Javascript add extra argument
javascript
Solution
`arguments` is not a pure array. You need to make a normal array out of it:
var mainArguments = Array.prototype.slice.call(arguments);
mainArguments.push("extra data");
Problem
Let's take a look at this code: ``` var mainFunction = function() { altFunction.apply(null, arguments); } ``` The arguments that are passed to `mainFunction` are dynamic -- they can be 4 or 10, doesn't matter. However, I have to pass them through to `altFunction` AND I have to add an EXTRA argument to the argument list. I have tried this: ``` var mainFunction = function() { var mainArguments = arguments; mainArguments[mainArguments.length] = 'extra data'; // not +1 since length returns "human" count. altFunction.apply(null, mainArguments); } ``` But that does not seem to work. How can I do this?