JSFiddle - React, Tailwind, and code Playground
by bhupendra negi
JavaScript
var arr = [10,5,10,6,2];
var arrObj = [];
things = new Object();
things.thing = new Array();
for(i=0;i<10;i++)
{
var obj = {};
obj.name = "name"+i;
if ( i == 4 || i == 5)
{
obj.reference = "xyz"
}
else if (i>7) {
obj.reference = "abc"
} else obj.reference = "ID"+i;
if (i==8 || i == 4) { obj.status ="forwarded" }
else if (i==9 || i == 5) { obj.status ="incoming" }
else obj.status = "temp"+i;
things.thing.push(obj);
}
var arr = {};
for ( var i=0; i < things.thing.length; i++ )
{ if( things.thing[i]['status'] != "forwarded" )
arr[things.thing[i]['reference']] = things.thing[i];
}
things.thingnew = new Array();
console.log("data values arr");
console.log(arr);
for ( var key in arr )
things.thingnew.push(arr[key]);
console.log("object of array of objects");
console.log(things);
console.log("dublicate array");
console.log(things.thingnew);