

For x in JavaScript - TrevorBurnham
http://iterative.ly/2010/05/22/for-x-in-javascript/

======
pan69
If you're new to Javascript/Actionscript/ECMAScript you might think there is a
difference between objects (maps) and arrays, but there isn't. An array is
simply a map (object) with the properties 0, 1, 2 etc. set to specific values.

This will list the properties of the map (0, 1, 2):

var a = ['a', 'b', 'c'];

for( i in a ) { console.log( i ); }

This will list the values of those properties:

var a = ['a', 'b', 'c'];

for( i in a ) { console.log( a[i] ); }

~~~
TrevorBurnham
And god help you if you've extended the Array or Object prototypes.

~~~
pan69
Amen

------
abdulhaq
I find it surprising that javascript gets so much traction as a hidden jewel
when really it's a pretty poor language compared to python, for instance. It
started off being pooh-poohed (including by myself) by those who thought that
it was some sort of cut-down 'scripting language' version of Java. Then
Douglas Crockford pointed out that you could do closures in Javascript and it
became kind of cool to praise Javascript. When I started using it (after
programming in C, C++, Lisp, Java, Python, etc.) I discovered an interesting
language but too many pain points (after the joy of python coding) to consider
it anything special.

