for (var temp = 2345, arr = []; temp;) { arr.unshift(temp % 10); temp = (temp - temp % 10) / 10 }; alert(arr);