Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

filter method 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: #filter #method #javascript
ADD COMMENT
Topic
Name
2+1 =