maybe I'm wrong but the last example of pureFunction mutates and returns one of its arguments. That's not a pure function.
Default arguments make the code harder to understand. It's often better to make two functions. If they are closely related then you can implement one in terms of the other. Even worse if the function behaves completely differently depending on how many arguments it takes (take the D3 setters/getters as an example).
function pureFunction(data) {
return pureFunctionWithIndexAndResult(data, 0, []);
}
function pureFunctionWithIndexAndResult(data, index, result) {
...
}> The concat() method returns a new array comprised of the array on which it is called joined with the array(s) and/or value(s) provided as arguments.
Taken from the MDN.