Javascript examples for Array Operation:Array Element
get similar string by comparing two strings arrays
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from w ww.j a v a 2 s. co m var array1 = ["test" , "testtest" , "aaa"]; var array2 = ["test" , "aaa"]; var arra3 =[]; for(i=0;i<array2.length;i++){ for(j=0;j<array1.length;j++){ if(array1[j].toLowerCase().indexOf(array2[i].toLowerCase())!=-1){ arra3.push(array1[i]); } } } console.log(arra3) } </script> </head> <body> </body> </html>