1const myNumber = 1245;
2function numberToArray(number) {
3 let array = number.toString().split("");//stringify the number, then make each digit an item in an array
4 return array.map(x => parseInt(x));//convert all the items back into numbers
5}
6//use the function
7var myArray = numberToArray(myNumber);
1const numToSeparate = 12345;
2
3const arrayOfDigits = Array.from(String(numToSeparate), Number);
4
5console.log(arrayOfDigits); //[1,2,3,4,5]
1const n = 123456;
2Array.from(n.toString()).map(Number);
3// [1, 2, 3, 4, 5, 6]
1const n = 123456;
2Array.from(n.toString()).map(Number);
3// [1, 2, 3, 4, 5, 6]
4