by jauco · 17y ago · 0 comments
[ y for ( y in [5,6,7,8,9] ) ] // is [0,1,2,3,4]
and [ y for each ( y in [5,6,7,8,9] ) ] // is [5,6,7,8,9]
Because in for extracts index names, and for each extracts the values.It will probably be a long time before 1.8 is supported by all browsers.
http://www.python.org/dev/peps/pep-0289/
The generator part in the example is the '(y in [])' the rest is a list comprehension (a short way of writing for loops that can be implemented very efficiently in a language and will return a list).
[UPDATE] Found a better explanation that also explains expression closures at http://ejohn.org/blog/javascript-18-progress/