Comment
Comment by cmwelsh
Avoiding nested anonymous functions is good for more reasons than listed in the article. The article lists closures holding references to the closed-over variables as being a source of wasted memory. Another point is the fact that anonymous variables require memory allocation each time they are created:
The function will be created every time the outer forEach loop is called.
Save your created functions for later to save memory.