(https://stackoverflow.com/questions/2218999/remove-duplicates-from-an-array-of-objects-in-javascript)
var arr=[
{"JANQTY":"49","STD_ITM_NM":"연결송수구명판" ,"EBGTAMT":"1" },
{"JANQTY":"38","STD_ITM_NM":"하론소화기" , "EBGTAMT":"0"},
{"JANQTY":"49","STD_ITM_NM":"연결송수구명판" ,"EBGTAMT":"0" },
{"JANQTY":"15","STD_ITM_NM":"압력스위치" ,"EBGTAMT":"0" },
{"JANQTY":"49","STD_ITM_NM":"연결송수구명판" ,"EBGTAMT":"1" }
];
console.log('BEFORE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :', arr);
console.log('BEFORE @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :', JSON.stringify(arr));
arr = [...new Map(arr.map(obj => [JSON.stringify(obj), obj])).values()];
console.log('AFTER @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :', arr);
console.log('AFTER @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ :', JSON.stringify(arr));
/*
Details:-
- Doing .map() on the data list and converting each individual object into a [key, value] pair array(length =2), the first element(key) would be the stringified version of the object and second(value) would be an object itself.
- Adding above created array list to new Map() would have the key as stringified object and any same key addition would result in overriding the already existing key.
- Using .values() would give MapIterator with all values in a Map (obj in our case)
- Finally, spread ... operator to give new Array with values from the above step.
*/