[
{name: 'Vasya'},
{name: 'Zina'},
{name: 'Vasya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
]
[
{name: 'Vasya'},
{name: 'Zina'},
{name: 'Petya'},
]
var src = [
{name: 'Vasya'},
{name: 'Zina'},
{name: 'Vasya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
];
var temp = [];
src.forEach(function(e){
if(temp.indexOf(e.name) == -1){
temp.push(e.name);
}
});
src = temp.map(function(e){
return {name:e};
});
console.log(src);
var src = [
{name: 'Vasya'},
{name: 'Zina'},
{name: 'Vasya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
];
var temp = {};
var result = [];
src.forEach(function(item) {
var name = item.name;
if (!temp[name]) {
temp[name] = true;
result.push(item);
}
});
console.log(result);
var a = [
{name: 'Vasya'},
{name: 'Zina'},
{name: 'Vasya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'},
{name: 'Petya'},
{name: 'Vasya'}
];
var b = _.uniq(a, 'name');
console.log(b);
var obj = {},
newmas = [],
i, max;
for (i = 0, max = mas.length; i < max; i += 1) {
if (!obj[mas[i].name]) {
obj[mas[i].name] = true;
newmas.push(mas[i]);
}
}