86
rated 0 times
[
88]
[
2]
/ answers: 1 / hits: 19761
/ 10 Years ago, wed, january 7, 2015, 12:00:00
I have an array like this:
var array = [ {
'data-price': '0.00',
'data-term': '532',
'data-model_id': '409',
},
{
'data-price': '0.00',
'data-term': '483',
'data-model_id': '384',
},
{ text: 'dffdfddgfdgf' } ];
I want to filter out the last object and extract [{data-model_id:409},{data-model_id:384}]
from the first two objects. I have tried this code:
var k = _(array).filter('data-model_id').pluck('data-model_id').value();
console.log(k);
and it returns an array of the values only, [409, 384]
. Is there a function to return the whole objects in lodash or underscore?
More From » arrays