Tutorial for Checking value from array javascript only. I found useful following URL working with Javascript Array.
http://www.javascriptkit.com/jsref/arrays.shtml
Here is my code to check value from array
var MyArrayVar = new Array(1, 2, 3, 4, 5); testVar = 2; if(MyArrayVar.indexOf(testVar) >= 0) { alert("We got testVar in MyArrayVar"); }else{ alert("We did not got testVar in MyArrayVar"); }
As per this condition I am chekcing the What is returned by this MyArrayVar.indexOf(testVar).
You can check this by using “alert(MyArrayVar.indexOf(testVar));” line.
You will get this number value if testVar number or value present in Array.
You that value is not present in Array you will get the -1 result always.