For example i have
var myArray =
[{
name: 'tom',
country: 'america',
favoriteFood: 'pizza'
},
{
name: 'gary',
country: 'france',
favoriteFood: 'pasta'
},
{
name: 'tom',
country: 'america',
favoriteFood: 'pizza'
},
{
name: 'lou',
country: 'brazil',
favoriteFood: 'fries'
},
{
name: 'gary',
country: 'france',
favoriteFood: 'pasta'
},
{
name: 'marge',
country: 'russia',
favoriteFood: 'steak'
}]
The function should return
[{
name: 'tom',
country: 'america',
favoriteFood: 'pizza'
},
{
name: 'gary',
country: 'france',
favoriteFood: 'pasta'
},
{
name: 'tom',
country: 'america',
favoriteFood: 'pizza'
},
{
name: 'gary',
country: 'france',
favoriteFood: 'pasta'
}]
I've tried numerous solutions from this site, however, i have yet to find something that will just return the values that are duplicated (culling the unique values). It is a bit difficult though, since javascript does not seem to have an integrated way to differentiate two objects, even if they have identical values.
Thanks for any help.