Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js remove json value duplicates

var data = [{
    "name": "Peter",
    "age": 30,
    "hair color": "brown"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}]

 data = this.data.filter((obj, pos, arr) => {
   return arr
     .map(mapObj => mapObj.name)
     .indexOf(obj.name) == pos;
 });

console.log(data);
/*
[{
    "name": "Peter",
    "age": 30,
    "hair color": "brown"
}, {
    "name": "Steve",
    "age": 55,
    "hair color": "blonde"
}]
*/
Comment

remove duplicate json object from array javascript

const temp =  [{first: 569, second: "789", third: "458"},  {first: 476, second : "147", third: "369"},  {first: 100, second: "200", third: "300"},  {first: 100, second: "200", third: "300"},   {first: 100, second: "200", third: "300"}];

const result = [...new Set(temp.map(obj => JSON.stringify(obj)))]
                 .map(str => JSON.parse(str));
console.log(result);
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs btoa 
Javascript :: javascript code to refresh page automatically 
Javascript :: react native gradient touchable feedback 
Javascript :: js array none 
Javascript :: nextjs websocket.js?a9be:46 WebSocket connection to 
Javascript :: js how to know if element touch border 
Javascript :: probability density function javascript 
Javascript :: add a text on last object map reactjs 
Javascript :: ryan dahl 
Javascript :: vue redirect to route 
Javascript :: remove floating point javascript 
Javascript :: download file axios nodejs 
Javascript :: first remove active class from classlist and append to current element using javascript 
Javascript :: font awesome shopping cart icon 
Javascript :: make created element brighter 
Javascript :: react native shadow generator 
Javascript :: javascript compare 2 thresholds color 
Javascript :: js nullish 
Javascript :: Sequelize find sort order 
Javascript :: jquery slideup 
Javascript :: jquery get select option attribute 
Javascript :: prisma studio 
Javascript :: js 1d index to 2d coord 
Javascript :: float force loopback 
Javascript :: javascript get diagonals of array 
Javascript :: getstaticpaths with redux 
Javascript :: hide / show jquery 
Javascript :: javascript reverse string without reverse method 
Javascript :: document.getElementById visual basic 
Javascript :: loopback user password setter overwrite 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =