Twitter Stream
Interesting News Items
Powered by Squarespace

Entries in Linq (1)

Friday
Feb192010

Linq for JavaScript

2010-02-19_jLinq[1] The past couple days I have been living on StackOverflow (I’m waiting on a client to give the go-ahead signal) and I came across an ad about jLinq.  Now, my first inclination was that of shock and bewilderment, but I’m starting to get over that.  jLinq is a Linq framework for working with Arrays in JavaScript.  If you don’t know about Linq then you probably don’t understand how awesomely scary that is.  Anyways, the syntax seems similar to the how C# works (with some added “memory” for previous actions). 

  1. <script type="text/javascript">
  2.     var results = jLinq
  3.         .from([
  4.             {name:"John", age:25, admin:true},
  5.             {name:"Mike", age:35, admin:false},
  6.             {name:"Randal", age:41, admin:false},
  7.             {name:"Stephanie", age:32, admin:true}]) // array of data
  8.         .ignoreCase()
  9.         .startsWith("name", "m") // "name" property starts with "a"
  10.         .or("j")                 // "name" property starts with "j"
  11.         .is("admin")             // "admin" property is true
  12.         .orderBy("age")
  13.         .select();
  14. </script>

While Linq is just a “less code” way of doing the same things you’ve been doing for years, I’m looking forward to using it and removing chunks of JavaScript loops.