How to filter objects from array javascript

 var products = [{"_id":1,"name":"product1 ","description":"good product"},

{"_id":2,"name":"product2 ","description":"good product"},

{"_id":3,"name":"product3 ","description":"good product"},

{"_id":4,"name":"product4 ","description":"good product"},

{"_id":5,"name":"product5 ","description":"good product"}]


 var newArray = products.filter(function (el) {

                return el._id > 2; 

              });


-------Output------

[{"_id":3,"name":"product3 ","description":"good product"},

{"_id":4,"name":"product4 ","description":"good product"},

{"_id":5,"name":"product5 ","description":"good product"}]

Comments

Popular posts from this blog

how to save images with angular nodejs

How to add splash screen and app icon with ionic capacitor angular android app