What is the leading LINQ for JavaScript library?
I recommend taking a look at underscore.js. It is not a direct LINQ port like some of the others, but is a very comfortable "LINQ-like" experience. It supports all the filter, sort and project options that I need and has excellent documentation and community support.
As a bonus for Knockout users, there is UnderscoreKO that adds Underscore's array methods to Knockout's observable arrays. Demo
The most basic and frequently used Linq operators are very commonly defined in widely used JS libraries. They just have different names (in fact, they have more traditional names than in Linq). Select
becomes map
, Where
becomes filter
, First
and FirstOrDefault
become [0]
.
Almost no library I know of (including I think the ones you linked to) bother to make the implementation lazy as in .NET Linq, they just evaluate immediately using arrays.
For a very nice, complete set of functional list operations, try: http://osteele.com/sources/javascript/functional/
Have you seen Rx for Javascript, yet? That's what you want.
You might want to check out linq.js. It follows the .NET lambda syntax and looks to be well integrated in a Microsoft environment.
LINQ for JavaScript - http://linqjs.codeplex.com/
Pros
- Implements all .NET 4.0 methods
- Complete lazy evaluation
- Full IntelliSense support for VisualStudio
- Supports jQuery
- Supports Windows Script Host
- Binding for Reactive Extensions for JavaScript(RxJS) and IntelliSense Generator
- NuGet install support
- Updated recently (last release Jan 2011)
- Syntax conforms to lambda syntax in C#
Cons
- The linq.js library is a little large.
- If you are already using jQuery or other js library, the most commonly used functionality is probably already available. See especially jQuery's filter, and 'Any' methods.