You must call the Array.prototype.filter function.
var filteredArray = YourArray.filter(function( obj ) { return obj.value === 1; });
.filter() requires returning the desired condition. It will create a new array based on the filtered results. If you want to work with filtered Array , you can call more methods, for example in your .map() instance
var filteredArray = YourArray.filter(function( obj ) { return obj.value === 1; }).map(function( obj ) { return obj.id; }); console.log( filteredArrays );
... and somewhere in the near future we can eventually use the Arrow functions for ES6, which makes this code even more attractive:
var filteredArray = YourArray.filter( obj => obj.value === 1 ).map( obj => obj.id );
jAndy source share