check if such element exist in array javascript es6 code example
Example 1: check if array does not contain value javascript
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango"); // true
var n = fruits.includes("Django"); // false
Example 2: how to check if an array contains a number in javascript
// To check if an array contains a number
const ratings = [1,2,3,4,5];
let result = ratings.includes(4);
console.log(result); // true
result = ratings.includes(6);
console.log(result); // false