Be aware that chaining methods on the Array prototype will cause the collection to be iterated many times (unlike LINQ which will iterate once when the collection is enumerated). This is because each method returns a new array.
Underscore allows single iteration chaining by using the chain and value methods.
LINQ | JS Array (ES6) | Underscore (ES6) | jQuery (ES6) |
---|---|---|---|
Any | some | some | N/A |
All | every | every | N/A |
Select | map | map | map |
Where | filter | filter | grep |
First/FirstOrDefault | find | find | N/A |
forEach | each | each | |
Max | N/A | max | N/A |
Min | N/A | min | N/A |
ToDictionary | N/A | groupBy | N/A |
Contains | includes | contains | N/A |
N/A | findIndex | indexOf | inArray |
Reverse | reverse | N/A | N/A |
String.Join | ["One", "Two"].join(", ") | N/A | N/A |
If I have missed anything please comment below and I will update the list.