short hand for chaining logical operators in javascript?
Posted
by Travis
on Stack Overflow
See other posts from Stack Overflow
or by Travis
Published on 2010-05-28T20:09:09Z
Indexed on
2010/05/28
20:12 UTC
Read the original article
Hit count: 341
Is there a better way to write the following conditional in javascript?
if ( value == 1 || value == 16 || value =-500 || value = 42.42 || value == 'something' ) {
// blah blah blah
}
I hate having all of those logical ORs strung together. I'm wondering if there is some kind of shorthand.
Thanks!
© Stack Overflow or respective owner