I have JavaScript code in my app that checks values using the OR(||) condition as in code snippet below. The number of OR conditions is not small in most of my code.
Question: Is there a way to make the code that has many multiple OR conditions more concise by using something like this:value IN ('s','b','g','p','z')
? I was interested in something that comes as close as possible to an IN clause.
if(value === "s" || value === "b" || value === "g" || value === "p" || value === "z") {
//do something
}
.indexOf()
– Herbal