check if value not in list javascript code example
Example 1: how to check if item is in list js
var myList=["a", "b", "c"];
mylist.includes("d")
Example 2: javascript array contains
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");
Example 3: Checking whether a value exists in an array javascript
const fruits = ['apple', 'banana', 'mango', 'guava'];
function checkAvailability(arr, val) {
return arr.some(arrVal => val === arrVal);
}
checkAvailability(fruits, 'kela');
checkAvailability(fruits, 'banana');