user10881682
user10881682

Reputation: 15

Is there a javascript equivalent to c#'s .All?

Hey Overflow Community,

I'm creating a QC check for duplicate rows in any of 3 tables. I've been running basic conditionals in my chrome console (javascript) then tweaking them to work for my C# script. I found a code block:

if (new[] { table1, table2, table3 }.All(x => x == 0))

I'd like to use this to create a conditional for if all values are equal to 0. Is there a Javascript equivalent to C#'s .All? Ideally I'd like to edit this statement to run in my chrome console.

Upvotes: 0

Views: 86

Answers (1)

Alejandro
Alejandro

Reputation: 7819

every is the function you're looking for. It has identical semantics to the LINQ's All. Your original code would be rewritten as this:

if ([table1, table2, table3].every(x => x == 0))

Look for the function's documentation for more details.

Upvotes: 1

Related Questions