-1

I have an array of objects as myData which consists of the below JSON structure:

const data = {
 myData: [
 { Type: 'REAL', Tenure: '12', Name: 'WEBPAGE' },
 { Type: 'REAL', Tenure: '24', Name: 'SERVER' },
 { Type: 'REAL', Tenure: '12', Name: 'WEBPAGE' },
 ],
};

I want to get rid of duplicate entries by keeping performance in mind as this array could be of length 1000+ using Javascript.

The Expected Output that I am looking for is as follow since myData[0] && myData[2] are duplicate here:

const result = {
 myData: [
 { Type: 'REAL', Tenure: '24', Name: 'SERVER' },
 { Type: 'REAL', Tenure: '12', Name: 'WEBPAGE' },
 ],
};
Sajeeb Ahamed
6,4482 gold badges23 silver badges36 bronze badges
asked Aug 9, 2021 at 6:24
1
  • First of all, How do you consider that two objects are duplicates? Are you matching all properties or just specific property? Commented Aug 9, 2021 at 6:30

1 Answer 1

0

You can use Lodash uniq function for more information please check https://lodash.com/docs/3.10.1#uniq

answered Aug 9, 2021 at 6:35
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.