var arr = [1,2,2,3,4,4,5,5,5,6,6,6,6]; function onlyOne(arr) { var brr = []; var crr = []; var index = null; for(i=0;i<arr.length;i++){ if(brr.indexOf(arr[i]) == -1){ brr.push(arr[i]); }else{ if(crr.indexOf(arr[i]) == -1){ crr.push(arr[i]); } } } for(i=0;i<crr.length;i++){ index = brr.indexOf(crr[i]); brr.splice(index,1); } return brr; } console.log(onlyOne(arr));