Array.prototype.includes with multiple arguments

# Shahar Or (8 years ago)

Hey everyone and thank you for making the JavaScript community as awesome as it is. It is only this awesome because it includes you.

community.includes(...members) // true
// will be equivalent to
members.every(m => community.includes(m)) // true

Is it backwards compatible?

Would you use it?

Any other thoughts, please?

# Oriol Bugzilla (8 years ago)

Array.prototype.includes uses the second argument as the starting index.

Therefore, these calls would be identical, but you want them to behave differently:

["a"].includes("a", 0); // true -- "a" can be found at position 0
["a"].includes(...["a", 0]); // false -- 0 can't be found in the array

So no, it wouldn't work well. Moreover, why every and not e.g. some?

But maybe new methods could be added, like includesEvery and includesSome.

# Shahar Or (8 years ago)

On Sat, Jun 11, 2016 at 12:01 AM Oriol Bugzilla <oriol-bugzilla at hotmail.com>

wrote:

Array.prototype.includes uses the second argument as the starting index.

Therefore, these calls would be identical, but you want them to behave differently:

["a"].includes("a", 0); // true -- "a" can be found at position 0
["a"].includes(...["a", 0]); // false -- 0 can't be found in the array

So no, it wouldn't work well. Moreover, why every and not e.g. some?

But maybe new methods could be added, like includesEvery and includesSome.

Right. I should've checked that. Yup, .includesEvery and .includesSome seem nice. I would call the latter .includesAny, I think.