Javascript examples for Array Operation:Array Search
Search if a value is in an array
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {// www . j a va 2 s . c om a = 1; b = [1,2,3,4]; function check(a,b){ for (var i=0;i<b.length;i++) { if (a == b[i]) { return true; } } return false; } console.log(check (a,b)) }); </script> </head> <body> </body> </html>