Just wondering what's the equivalent of the each do function from Ruby to JS?
For example:
$data_actors.each do | actor | #do stuff here endThanks in advance.
Thanks. It is working now, but I wonder why it says that the actor is undefined but when I log it, it says its an Actor object. Figures.
Honestly, i wouldn't bother. Native for-loops are always faster than Array iterators and i prefer performance over "elegant" code.
There is an exception, though: If you want to remove elements from an array while iterating over it, you would need to iterate in reverse or also modify the index, which might not be feasible. Array.forEach creates a shallow copy from the array it iterates over and as such allows modification during the loop.