我创建了如下数组,
arr =[ {uName:"2015", 1:100,2:10,3:0},{uName:"2011",1:10,2:2,3:19},{uName:"2015",1:10,2:0,3:20}],
在这里,我需要选择arr[0][1]
和arr[2][1]
where uName is "2015"
。
Linq 查询是,
$.Enumerable.From(arr).Where(function(n){n.uName =="2015"}).Select(function(y){return y.1}).Sum()
预期的答案是:
arr[0][1] = 100, arr[2][1] = 10 (or) sum of these value 110 (arr[0][1] + arr[2][1])