Write a function to remove duplicate elements from an array.

AnswerBot
1y

Remove duplicate elements from an Array

  • Use the Set object to remove duplicate elements

  • Convert the Set back to an array using the spread operator

  • If the array contains objects, use a custom comparison f...read more

Shivam Holkar
5mo
const array = [1, 2, 3, 2, 4, 1, 5]; const uniqueArray = [...new Set(array)]; console.log(uniqueArray);
Rahul Gabhane
3y

var arr=[2,3,6,2,5,3.4,6,5];

var res=[];

arr.filter((v)=>{if(!res.includes(v)){

res.push(v);

}})

console.log(res);

Anonymous
4y
This question has been asked to me in at least 4-5 interviews. This can be done in several way. The most efficient way being, Create a new "Set" from the existing array. This is an es6 functionality. ...read more
Select
Add answer anonymously...

Accenture Front end Developer interview questions & answers

A Front end Developer was asked 8mo agoQ. How do you use Redux?
A Front end Developer was asked 8mo agoQ. How do you create custom hooks?
A Front end Developer was asked 9mo agoQ. Explain the difference between a promise and an observable, and provide a use ca...read more

Popular interview questions of Front end Developer

A Front end Developer was asked 8mo agoQ1. How do you create custom hooks?
A Front end Developer was asked 9mo agoQ2. Explain the difference between a promise and an observable, and provide a use ca...read more
A Front end Developer was asked 11mo agoQ3. How do you handle form validation?
Accenture Front end Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits