var arr = [1,1,2,5,9,9,7,7]; function unq(arr) { var obj = {}; for(var i = 0; i < arr.length; i++){ var num = arr[i]; obj[num] ? delete obj[num] : obj[num] = 1; } return Object.keys(obj).map(n=>+n); } console.log(unq(arr));