How To Check Is Value Exists In Array

[Solved] How To Check Is Value Exists In Array | Solidity - Code Explorer | yomemimo.com
Question : Check if the value exists in Array in Javascript

Answered by : putu-eka-mulyana

var army= ["Marcos", "DeltaForce", "Seals", "SWAT", "HeadHunters"];
if(army.indexOf("Marcos") !== -1) { console.log("Yes, the value exists!")
}else{ console.log("No, the value is absent.")
} 

Source : https://www.javatpoint.com/check-if-the-value-exists-in-array-in-javascript#:~:text=The%20indexof()%20method%20in,found%20and%20returns%20%2D1%20otherwise. | Last Update : Fri, 14 Oct 22

Question : check value exist in array javascript

Answered by : prafy

[1, 2, 3].includes(2); // true
[1, 2, 3].includes(4); // false
[1, 2, 3].includes(1, 2); // false (second parameter is the index position in this array at which to begin searching)

Source : https://stackoverflow.com/questions/7378228/check-if-an-element-is-present-in-an-array | Last Update : Sat, 04 Jul 20

Answers related to how to check is value exists in array

Code Explorer Popular Question For Solidity