Javascript examples for Array Operation:Array Index
Get array elements whose index is matching variable with array filter method
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//w w w . j a va 2s . co m var numbers = ["one", "two", "three", "four", "five", "six", "seven"]; var search = 'f'; console.log(numbers.filter(function(x){ if(x.indexOf(search) >= 0) return x })) } </script> </head> <body> </body> </html>