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
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?
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

