query javascript array of objects

I hope this post will help many javascript developers to filter their JSON and reduce the amount of work and stress.

I find many javascript developers still writing loops to match a key to get the object from an array of objects. I agree it’s the simplest method to get the required element but on the other side what if the array of objects has hundreds of elements and the element required is the last one.

Considering the performance as the first priority I suggest to query the JSON array and get the element required in two lines without looping through entire array.

Now the question is how to achieve that?

It’s very simple and easy, there are multiple libraries available which you may just have to include them in your project and follow the syntax.

As i said there are multiple libraries present but i prefer suggesting “JSLINQ” and “linq.js” which are easy to implement and open source plugins.


JSLINQ is the basic of all, It provides the ability to query (more like SQL) against arrays. This has minimum number of features and supports the basic queries.Download and Checkout the examples at

download JSLINQ

You can also check the different querying options available and edit them according to your requirement using an online editor present at

JSLINQ editor

Let’s move on to linq.js which is used for many complicated situations like GroupJoin etc…

This library provides around 90 different type of querying options(mostly the ones supported in .NET 4.0). Using the library would be similar to JSLINQ whereas the syntax differs.

linq.js also supports short form syntax and if you’re someone who is looking for compatibility with C# or a library which allows jquery selections then linq.js would be the best option. You can download the source code from

download linq.js

Happy coding……………….:)

Tagged as: , ,