var arr=[2,8,5,0,5,2,6,7,2]; //es6 function uniqueEs6(arr){ var newArr = new Set(arr) ; return [...newArr] } //indexOf function unique(arr){ var newAr ...
var arr=[2,8,5,0,5,2,6,7,2]; //es6 function uniqueEs6(arr){ var newArr = new Set(arr) ; return [...newArr] } //indexOf function unique(arr){ var newArr=[] ; for(var i=0;i<arr.length;i++){ if(newArr.indexOf(arr[i]==-1)){ newArr.push(arr[i]) ; } } return newArr ; }