Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

...new Set() in javascript

let Arr = [1,2,2,2,3,4,4,5,6,6];

//way1
let unique = [...new Set(Arr)];
console.log(unique);

//way2
function removeDuplicate (arr){
	return arr.filter((item,index)=> arr.indexOf(item) === index);
}

removeDuplicate(Arr);

Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
9+2 =