My understanding is that bellow code will create an array name digits which contains all digits from n, I'm I right?
var n = 123456789; var digits = (""+n).split("");
But I did'n understood (""+n) ? Can anyone help me? Thanks in advance.
When concat a number with string, js cast it to string. In your code, n is number, but when concat with a empty string(""), casting to string. In other way you can call toString() function. You can run follow snippet to try it
var n = 123456789;
console.log(typeof n); //number
console.log(typeof (""+n)); //string
console.log((""+n).split(""));
console.log(n.toString().split(""));