Alex Rivera | Logout

What is this JavaScript construct: " = [y for each ...]"

Asked 2010-02-10T17:07:41.260
9
myColl.y = [y for each (y in myColl.y) if (y != myThing.getY())];

I understand what this is doing, returning all the 'y' items that are not the current one...

But, what is the concept called here with the brackets? I would like to read up on what this is , syntax, etc.

Edit
Report

1 Answer

9

It's an array comprehension.

Apparently this was introduced in Javascript 1.7.

answered 2010-02-10T17:10:51.797

Your Answer