I want to convert an integer, say 12345, to an array like [1,2,3,4,5].
12345
[1,2,3,4,5]
I have tried the below code, but is there a better way to do this?
var n = 12345; var arr = ('' + n).split('').map(function(digit) {return +digit;});
The map function, though, is only supported by recent browsers.