Javascript examples for Array Operation:Array Element
Remove array element by condition with for loop and if statement
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from www .ja v a2 s. c o m var ar = [ {num:1, str:"a"}, {num:2, str:"b"}, {num:3, str:"c"} ]; var newArray = []; for (var i = 0, len = ar.length; i<len; i++) { if (ar[i].str == "b"){ newArray.push(ar[i]); } }; console.log(newArray); } </script> </head> <body> </body> </html>