Checking for Array Membership in Javascript


Use .includes() to check if an array contains a certain element.

Source Code

let pets = ['dog', 'cat', 'rabbit'];
console.log(pets.includes('cat')); // true
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments