1

Closed

Create ".Each" method

description

Create ".Each" or ".ForEach" methods to allow for more easy looping through the set of data within the JSLINQ object.
 
Example Usage:
 
function displayData(dataItem){
alert(dataItem);
}
 
var newArray = exampleArray.
Where(function(item){ return item.FirstName == "Chris"; }).
Select(function(item){ return item.FirstName; });
 
newArray.Each(displayData);
 
newArray.ForEach(function(item){
alert(item);
});
Closed Oct 25, 2010 at 1:26 PM by crpietschmann
Done

comments

crpietschmann wrote Feb 25, 2010 at 7:11 PM

Probably good idea to look at jQuery methods for inspiration on how to make this work best.

gshackles wrote Mar 17, 2010 at 3:27 AM

Just noticed this issue...I actually just put up a new blog post about using/extending JSLINQ, and include a sample implementation for ForEach: http://www.gregshackles.com/2010/03/linq-for-javascript-using-and-extending-jslinq/

Oddly enough, I based mine on jQuery's implementation of each(). There could be room for improvement, but I think it's a good starting point.

wrote Oct 25, 2010 at 1:25 PM

wrote Oct 25, 2010 at 1:26 PM

wrote Oct 25, 2010 at 1:26 PM

wrote Feb 14, 2013 at 8:18 PM

wrote May 16, 2013 at 10:05 AM