How to search for a value in an Array of JavaScript? -


this question has answer here:

i learning javascript , came across problem. want catch input value using document.formname.elementname.valueand compare value instance of array object.if value exists throw alert!.

you can use indexof() function : array.indexof("string") return -1 if item not found, otherwise position. here's link w3schools.


Comments