alexa
Facebook
Twitter
LinkedIn
Instagram
Whatsapp
Call Now
Quick Inquiry

Remove the second occurrence of array object with same name in JS ?

Remove the second occurrence of array object with same name in JS ?

Try This Code 

 let users = [{name:'arrow',age:50,id:444},
  {name:'bow',age:66,id:884},
  {name:'arrow',age:30,id:99},
  {name:'apple',age: 50,id: 990},
  {name:'bow',age: 50,id: 9669}]

for (let i = 0; i < users.length; i++) {
  for(let x = 0; i < users.length; i++) {
    if(users[i].name == users[x].name) {
      users.splice(users[x], 1)
    }
  }
}

68 0
7

Write a Comments


* Be the first to Make Comment

GoodFirms Badge
GoodFirms Badge

Fix Your Meeting With Our SEO Consultants in India To Grow Your Business Online