A few tips on how to work better with Arrays in JS

added by JavaScript Kicks
10/20/2014 1:21:43 PM


If you're like me who always end up using for loop to do any operation involving arrays, you should probably have a look below at some "hidden" methods available in ECMAScript5 (the current version on Javascript) to work with Arrays. I say "hidden" because these functions I'm going to show you are available for a while in most of the browsers but most of the people haven't heard about them or haven't used them yet.


Drew Peterson
10/20/2014 5:33:38 PM
It should also be noted that if performance is a concern (and it should be!), the native forEach is much more performant than a for or while loop http://jsperf.com/es5-array-foreach-vs-loop/2 It's also good to familiarize yourself with all the ES5 goodies now available in modern browsers http://kangax.github.io/compat-table/es5/

Robert Greyling
10/20/2014 6:13:21 PM
Looks like those could be links all of their own ;)