Why would we need myStringFruit.in(fruits) when we have fruits.includes(myStringFruit)? That seems like it'd be adding an extra thing to the language (a very expensive proposition) solely so "collection includes item" could be written in reverse, as "item is in collection".
I don't think an in method provides more clarity than the reverse. In addition, it seems to be on the wrong side - checking for existence is the responsibility of the collection, not of any arbitrary values:
value.in(collection) should work for a collection that is an array, a set, an iterator, etc. It would need to dispatch to the collection-specific method anyway (using a Symbol approach, similar to String's split and match methods supporting arbitrary patterns)
value.in(collection) should work for arbitrary values, including null, undefined and Object.create(null), which JavaScript is not designed to support. It seems you are proposing an in method only for strings?!
seems right bergus, i only want to clarify like sql sintax, but I agree that it can be solved in reverse.
in sql familiar sintax clarify
...
WHERE fruit IN ( ..... a list of elements)
I found it interesting to propose it
a single element (string) is in a group (Array or Set or Map)
Can be usefull with Numbers too looks this
var myNumer = 123;
if myNumer==11 || myNumer==22 || myNumber==54 || myNumber==55....
this can be solved simplifyg in this form:
myNumber.in(11,22,54,55)
avoiding wrong writing (the variable is writed only once)