Javascript examples for Array:filter
Remove items from dynamic array with filter function
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w ww . j a va2 s .co m var yourArray = [{ id: 1, msg: "hello" }, { id: 2, msg: "help" }, { id: 1, msg: "bye" }]; var newArr = yourArray.filter(function (item) { return item.id === 1; }); console.log(newArr); } </script> </head> <body> </body> </html>