Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove duplicates in javascript array (using set)

const arrayWithDuplicateValues = [1, 2, 2, 3, 4, 5, 6, 7, 7, 7, 8, 9];
const uniqueValues = [...new Set(arrayWithDuplicateValues)];

console.log(uniqueValues);

//same code with spread operator


const arrayWithDuplicateValues = [1, 2, 2, 3, 4, 5, 6, 7, 7, 7, 8, 9];
const uniqueValues = Array.from(new Set(arrayWithDuplicateValues));

console.log(uniqueValues);
Source by geshan.com.np #
 
PREVIOUS NEXT
Tagged: #remove #duplicates #javascript #array
ADD COMMENT
Topic
Name
8+2 =