Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript check if array has a certain element

// check if an array INCLUDES a certain value

//array for includes()
let numbers = [1, 2, 3, 4, 5]

// either true or false 
numbers.includes(2) // returns true, the numbers array contains the number 2

numbers.includes(6) // returns false, the numbers array DOESNT contain the number 6
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #check #array #element
ADD COMMENT
Topic
Name
1+3 =