There's a great answer in 
this post on stackoverflow about iterating through array entries.  The answer author goes to great length to illustrate the the different methods, their pros and cons.
- Use forEach and related (ES5+)
- Use a simple for loop
- Use for-in correctly
- Use for-of (use an iterator implicitly) (ES2015+)
- Use an iterator explicitly (ES2015+)
Some of this information may be dated, especially when it comes to updated releases of ECMAScript.  Nevertheless, this is a link that's probably worth keeping around. 
No comments:
Post a Comment