Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript match against array

// This long line of expression
x === 'firstmatch' || x === 'secondmatch' || x === 'thirdmatch'

// Can be shortened like this:
['firstmatch', 'secondmatch', 'thirdmatch'].includes(x)
 
PREVIOUS NEXT
Tagged: #javascript #match #array
ADD COMMENT
Topic
Name
2+6 =