

There's no more fiddling around with indices just to determine array membership. Notice how the if-condition almost reads like a regular English sentence. The () method makes this check easier to read and more semantically meaningful to human readers: const numbers = Up until now, you've probably compared the return value of the () method against -1 to check whether an array contains a certain value: const numbers = The other new feature is the exponentiation operator **, which provides a little syntactic sugar for Math.pow. () determines whether an array contains a given element and returns either true or false. The () method defined on the Array prototype is one of the two new features that ECMAScript 2016 standardizes. Var resultI=new LINQ(data).ECMAScript 2016: () February 3, 2016 Searching for value 19 makes your hasElement function very limited, it would be a more flexible function if you pass the row and the search value.Īll in all, I would counter-propose something like this: var LINQ = require('node-linq').LINQ You basically rewrote Array.indexOf, except that indexOf gives more info (where is the element), so I would rewrite this with indexOf. I think it is better form to place your requires all the way on the top Your braces are not styled consistently, and most JavaScript developers find sameline braces more idiomatic. Var resultI=new LINQ(data).Any(function(row)Ĭan this be improved? please any suggestions will be quite appreciated. Var result = c.SelectMany(x => x).SelectMany(x => x).Any(p => p = 2) īut since I'm exploring the LINQ capabilities in node js, I decided to extend this to an Array of Arrays var data=, , ] checking if the value is in any of the collections. Example of such structure Check a List> contains a value using Linq List a= new List() In C#, I could check if any of the nested List collection has a value.
