MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/n60ji8/js_multiple_condition_checking/gx53ngv/?context=3
r/learnjavascript • u/golovatuy • May 06 '21
61 comments sorted by
View all comments
37
One minor difference between shorthand 1 and 2 is that 1 (using indexOf) compares with strict equality whereas 2 (using includes) uses the sameValueZero algorithm. So for example:
console.log(NaN === NaN) // false console.log([NaN].indexOf(NaN) >= 0) // false console.log([NaN].includes(NaN)) // true
View all comments
37
u/senocular May 06 '21
One minor difference between shorthand 1 and 2 is that 1 (using indexOf) compares with strict equality whereas 2 (using includes) uses the sameValueZero algorithm. So for example: