mihaifm / linq

linq.js - LINQ for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do we work with the selected items

mwpowellhtx opened this issue · comments

Hello, let's say I have the casual array:

var values = [1, 2, 3];

I want to select from that array and work with the results, right?

var selected = Enumerable.from(values).where(x => x%2 !== 0);
console.log("number of odd values: " + selected.length); // Expecting 2

However, what is returned from Where appears to be an Linq object wrapper of some sort.

How do I extract the actual values from the expression?

Otherwise, cannot give enough 👍 for this type of library package.

Thanks!

commented

Just like in C#: if you want an array, call .toArray()

Well, I'd clarify, not quite like C# in the sense that what is returned from .where(...), etc, is not an "enumerable", or I do not know how to work with it naturally in JavaScript. That said, good to know re: .toArray(). Thanks for pointing that out.