Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 502
Scott Szretter Avatar asked Feb 10 '10 17:02

Scott Szretter


1 Answers

It's an array comprehension.

Apparently this was introduced in Javascript 1.7.

like image 75
Stefan Kendall Avatar answered Oct 09 '22 20:10

Stefan Kendall