Javascript examples for Array Operation:Array Element
Rearrange JavaScript array using match
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . ja v a 2s . c om var arr = ["A C", "B B", "C"]; var newarr = []; var str = "C"; for(var i = 0; i < arr.length; i++) { if(arr[i].toLowerCase().match(str.toLowerCase())){ newarr[newarr.length] = arr[i]; } } console.log(newarr); } </script> </head> <body> </body> </html>