var arr = [2,1,4,3,2,4,2,3,4,2,6,5,5] var obj = {}; var arrNew = []; for(var i=arr.length-1;i>=0;i--){ if(!obj[arr[i]]){ obj[arr[i]] = true; arrNew.push(arr[i]); } } console.log(arrNew,obj)// [5, 6, 2, 4, 3, 1] Array.prototype.unique2 = function(){ t