Javascript examples for Array:indexOf
Remove values from an array that are in a second array with filter function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . j a va 2 s . c o m var array1 = [ 1, 2, 3, 4, 5 ]; var array2 = [ 2, 3 ]; var result = array1.filter( function ( elem ) { return array2.indexOf( elem ) === -1; }); document.write( result ); } </script> </head> <body> </body> </html>