2 August 2011

Can i use for in loop for arrays?

It is possible to use for-in loop  for arrays,
  • it can cause some dodgy  logical errors 
  • order of listening the properties can be a little bit random (It's not quaranteed) 
 So it is highly NOT RECOMMENDED to use for in for arrays.

Just remember:
use   for loops with arrays and for-in loops for objects .

Source: Stoyan Stefanov - JavaScript Patterns  - O'Reilly(2010)