How to correct following code for desired output,
var Data = [{ "A": -27, "B": -39 }, { "A": 28, "B": 0}]
var filter = "x[A]==28";
var findItem = Enumerable.From(Data)
.Where(function (x) { return filter ; })
.ToArray();
alert(findItem.length);
$.each(findItem, function (i, value) {
alert(value["A"]);
});
It should give me one value A:28 or complete one record { "A": 28, "B": 0}, why i am getting two values, How to get correct results ?
using "linq.js" from following path: [ https://raw.github.com/gist/1175460/fb7404d46cab20e31601740ab8b35d99a584f941/linq.js ]
code at JSfiddle: http://jsfiddle.net/Irfanmunir/gLXNw/2/
your filter is a string which always evaluates to true. put your filter inside a function:
var filter = function(x) { return x['A'] === 28 };
and use this:
.Where(filter)
see updated fiddle: http://jsfiddle.net/gLXNw/4/