Reputation: 5
I have an array of arrays, i.e. [ [1,2], [1,3] ]
and I want to check if is there any 1 as the first element of a subarray. It doesn't matter if it is a [1,2]
or [1,3]
. I'm interested only in the 1's existence. Sure I could use some loops to do this, but I wonder if is there an elegant "built-in" way to do this in js, something like:
arr.includes([1, _]) // returns true if is there any 1 as first element of an array
Upvotes: 0
Views: 110