by fmarguerie via Fabrice's weblog on 12/28/2006 11:41:00 AM
Nikhil Kothari, whose blog you should visit immediately if you're doing web development, demonstrates how to reproduce LINQ to Objects in JavaScript.
Nikhil is an architect on the Web Platform and Tools team at Microsoft known for his great projects, past and present, which include: ASP.NET Web Matrix, Web Development Helper, and Script#.
This time, Nikhil has a post in which he demonstrates how it's possible to write queries against JavaScript arrays, similarly to what LINQ to Objects offers for C# and VB.NET.
The following LINQ query in C#:
var someLocations = from location in allLocations where location.City.Length > 6 select new { City = location.City, Country = location.Country };
can also be written as follows using query operators:
var someLocations = allLocations .Where(location => location.City.Length > 6) .Select(location => new { City = location.City, Country = location.Country });
The equivalent query could be written in JavaScript as follows:
var someLocations = allLocations .filter(function(location) { return location.City.length > 6; }) .map(function(location) { return { City: location.City, Country: location.Country }; });
Pretty close, isn't it? Learn more...
Original Post: LINQ to Objects for JavaScript
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.