I am just wondering if there is any way to do something like:
if(myVar === 1|2|5) {do something}
or
if(myVar === (1 || 2 || 5)) { do something }
which will work as
if(myVar === 1 || myVar === 2 || myVar === 5) {do something}
Using switch case is not optional solution too. Also It should work with any data type not just numbers, but strings, arrays. basically a comparison. I have already tried the first two examples and it did not work, probably it's not meant to work like that.
I am specially interested in JS and PHP, other languages are welcome for other readers.
UPDATE
"in_array" or "indexOf" or writing an inline statement is not what kind of answer i am looking for. since i know about these functions I develop for 8+ years.
Let me explain: Since I work with react I am learning JS and I have found lot of new tricks in javascript syntax like:
myArray.find(item => (item.id===something)) vs .find(function(item) {....})
const printHello = () => { return "hello" } vs const printHello = function() { .... }
[1,2,3,4,...varWithOtherNumbers] vs concat
And lot of other tricks.
So I am just wondering if there is maybe a not well known javascript syntax trick.