JavaScript Iterator Class

后端 未结 7 1309
挽巷
挽巷 2020-12-29 07:55

Do you know a JavaScript library that implements a generic Iterator class for collections (be it Arrays or some abstract Enumerable) with a full set of features, like the Go

7条回答
  •  隐瞒了意图╮
    2020-12-29 08:24

    Ive used LINQ to Javascript in a few projects.

    http://jslinq.codeplex.com/Wikipage

    var myList = [
                {FirstName:"Chris",LastName:"Pearson"},
                {FirstName:"Kate",LastName:"Johnson"},
                {FirstName:"Josh",LastName:"Sutherland"},
                {FirstName:"John",LastName:"Ronald"},
                {FirstName:"Steve",LastName:"Pinkerton"}
                ];
    
    var exampleArray = JSLINQ(myList)
                       .Where(function(item){ return item.FirstName == "Chris"; })
                       .OrderBy(function(item) { return item.FirstName; })
                       .Select(function(item){ return item.FirstName; });
    

提交回复
热议问题