In a a dojo / javscript application
I am trying to figure the most efficient way to find the duplicates in this list of objects below:
{ item: "A", value: "one" },
{ item: "B", value: "two" },
{ item: "C", value: "three" },
{ item: "B", value: "two" },
{ item: "D", value: "five" },
{ item: "C", value: "three" }
so what I need as a finished product is:
not found list:
{ item: "A", value: "one" },
{ item: "D", value: "five" }
found list:
{ item: "B", value: "two" },
{ item: "C", value: "three" }
Also, I am using DOJO AMD so I know I have forEach, filter, some available to me
I know I can do a first pass to get the duplicate value:
var split = function( list )
{
var found = [];
var objectList = lang.clone( list );
var test = objectList.pop();
objectList.forEach( function( inner )
{
if( test.item == test.item )
{
found.push( test.item );
}
} );
return found;
};