javascript in array
snippet in javascript

javascript array contains

user7687

var colors = ["red", "blue", "green"];
var hasRed = colors.includes("red"); //true
var hasYellow = colors.includes("yellow"); //false

javascript in array

user7769


var fruits = ["Banana", "Orange", "Apple", "Mango"];

var n = fruits.includes("Mango");
 

javascript is string in array

user7439

var colors = ["red", "blue", "green"];
if(colors.indexOf("blue") !== -1){
	//colors contains the string "blue"
}else{
	//colors does not contain the string "blue"
}

javascript element in array

user8875

var fruits = ["Banana", "Orange", "Apple", "Mango"];

var n = fruits.includes("Mango");

javascript check if value in array

user7331

var fruits = ["Banana", "Orange", "Apple", "Mango"];
var n = fruits.includes("Mango");

how to check if item is in list js

user6429

var myList=["a", "b", "c"];
mylist.includes("d")//returns true or false