Array.prototype.includes

The includes() method determines whether an array contains a specified element (including NaN unlike indexOf).

This method returns true if the array contains the  element, and false if not.


const arr = [1, 2, 3, 4, NaN];
console.log(arr.includes(4)); //true
console.log(arr.includes(5)); //false
console.log(arr.includes(NaN)); //return true

Leave a Reply

Your email address will not be published. Required fields are marked *