Is it possible to use multiple arguments when determining indexOf
on an array?
I want to determine if my array contains any of three integers. Important to note at this stage that the array will only have one value (if it has more, it won't reach this code block).
array.indexOf(123 || 124 || 125) === 0
So if array = [123]
then my indexOf
should be 0
and therefore true
.
If array = [124]
then my indexOf
should be 0 and therefore true
.
What I am finding is happening is [123]
works OK but it's not even bothering to check the indexOf
for the 2nd or 3rd arguments, and is just returning false.
indexOf
to accept multiple arguments, e.g.indexOf(1, 2, 3)
, because in the general case, what should the result be if multiple elements exist in the array…? – Ernieernst