There is no else statement in your code, and the recursive call is incorrect (you pass the same array over and over, and not pass its elements).
Your function can be written as follows:
function flatten() { // variable number of arguments, each argument could be: // - array // array items are passed to flatten function as arguments and result is appended to flat array // - anything else // pushed to the flat array as-is var flat = [], i; for (i = 0; i < arguments.length; i++) { if (arguments[i] instanceof Array) { flat = flat.concat(flatten.apply(null, arguments[i])); } else { flat.push(arguments[i]); } } return flat; } // flatten([[[[0, 1, 2], [0, 1, 2]], [[0, 1, 2], [0, 1, 2]]], [[[0, 1, 2], [0, 1, 2]], [[0, 1, 2], [0, 1, 2]]]]); // [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]