Here is the json data
var myArray = [{
id: '71',
os: 'VM-WIN7-64'
}, {
id: '45',
mode: 'weekly',
os: 'VM-WIN7-32'
}, {
id: '37',
os: 'VM-WIN7-64',
}, {
id: '67',
mode: 'daily',
os: 'VM-WIN7-32-1',
}];
From this how can i filter only mode:daily, mode:weekly as below.I have to remove other values except mode:daily``mode:weekly
var myArray = [{
id: '45',
mode: 'weekly',
os: 'VM-WIN7-32'
}, {
id: '67',
mode: 'daily',
os: 'VM-WIN7-32-1',
}];
Use the Array#filter method.
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
myArray = myArray.filter(function(o){
return (o.mode === 'weekly' || o.mode === 'daily');
});
JSFIDDLE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With