I've the following array I need to return only the uniqe ID for example since in this array I have twice id 1 & 3 I need new array with just the first findigs id,
In this example the first 3 entries, how I can use it with maps/filter and not with regular for
var oData = [{
id: 1,
ListTypeGroupDescription: 2,
test: 111,
test2: 222
}, {
id: 2,
ListTypeGroupDescription: 4,
test: 333,
test2: 444
}, {
id: 3,
ListTypeGroupDescription: 6,
test: 666,
test2: 777
}, {
id:1,
ListTypeGroupDescription: 99,
test: 666,
test2: 777
}, {
id: 3,
ListTypeGroupDescription: 99,
test: 666,
test2: 777
}];
var data = oData.map(
function(obj) {
return obj.id;
}
);
http://jsfiddle.net/5qu0j8g0/1/
The map is returning only the ID's but I need the all objects
I need this newArray
var oNew = [{
id: 1,
ListTypeGroupDescription: 2,
test: 111,
test2: 222
}, {
id: 2,
ListTypeGroupDescription: 4,
test: 333,
test2: 444
}, {
id: 3,
ListTypeGroupDescription: 6,
test: 666,
test2: 777
}
]