I have a structure like this:
var arr = [
{
title: 'anchorman'
},
{
title: 'happy gilmore'
},
{
title: 'anchorman'
}
]
Now what would i have to do to end up with an array like this:
var arr = [
{
title: 'anchorman'
}
]
So it not only remove entries that are unique but just leaves a single entry for a duplicate.
I have this so far but it is not good!
var ref;
for(var i in movies) {
ref = movies[i].title;
if(this.titles.indexOf(ref) == -1) {
movies.splice(i, 1);
} else {
this.titles.push(ref);
}
}
where 'movies' is the first array in this question and this.titles is simply an empty array.