ES5
var array= [1,5,2,3,4,2,3,1,3,4]
function unique(arr){
var unique_array = []
for(var i = 0;i < arr.length; i++){
if(unique_array.indexOf(arr[i]) == -1){
unique_array.push(arr[i])
}
}
return unique_array
}
console.log(unique(array)); //[1,5,2,3,4]
ES6
var array= [1,5,2,3,4,2,3,1,3,4]
function unique(array) {
return [...new Set(array)]
}
console.log(unique(array));//[1,5,2,3,4]