JavaScriptCheatSheet
JavaScriptCheatSheet copied to clipboard
forEach does not modify the array
In the subsection Array Methods:
With the exception of
forEach, the above functions do not modify the array they are given.
forEach behaves exactly in the same manner as the rest of those functions. None of them, forEach included, modifies the original array.
(But also none of them can prevent that you change it inside the iterating function)
In the subsection Array Methods:
forEach takes in each element and consider it for some action, all those mentioned in the section doesn't alter the original array.
suggested fix:
xs.forEach(a) to loop over the elements in an array and perform some action.