Closed chris-kruining closed 4 years ago
I dont believe arguments would be removed, the spread operator in this context wouldn't work without it.
Side note, forEach is just syntax sugar that is less efficient when used in this context. For each does a for loop anyway, now instead of calling the add function, you introduced an inline closure that then does the call to add function. So your proposed solution goes from one Loop that does a single function call per iteration, to a Function call that generates a for loop, that then calls a function who's whole purpose is to call another function for each iteration. Syntax wise it looks nice, but performance wise, its less efficient.
Now, I'm not against forEach or closures, they have their purpose. Like an array sort function is a good example why a ForEach and Closure makes more sense, this way you can make the compare function that it uses be programmer defined, any other way it would probably complicate things.
I agree on the foreach discussion, just a habit of mine to prefer readable oneliners.
argumants is an old mechanism and I wouldn't be suprised if it were to be removed.