0

How to remove duplicate elements in an array in Javascript?

I don't think I learned it.

15th Jan 2021, 4:40 PM
aka :)
aka :) - avatar
5 Respostas
+ 3
Use a for loop to loop through the array and push each item to another new array on one condition, the condition is that it must not be already present in the new array. Tip: You can check that if a value exists in an array using arr.includes(value)
15th Jan 2021, 4:48 PM
maf
maf - avatar
+ 3
arr = [...new Set(arr)];
15th Jan 2021, 4:49 PM
visph
visph - avatar
+ 2
Med Amine Fh You should know how to do it manually before using the advance ways.
15th Jan 2021, 5:33 PM
maf
maf - avatar
+ 1
use visph way its more easier
15th Jan 2021, 5:27 PM
Med Amine Fh
Med Amine Fh - avatar
+ 1
Agree maf
15th Jan 2021, 6:19 PM
Med Amine Fh
Med Amine Fh - avatar