convert number to array of numbers javascript code example
Example 1: javascript Convert an array of strings to numbers
const toNumbers = arr => arr.map(Number);
toNumbers(['1', '2', '3','4']); // [1, 2, 3, 4]
Example 2: number to array javascript
const n = 123456;
Array.from(n.toString()).map(Number);
// [1, 2, 3, 4, 5, 6]
Example 3: integer to array javascript
Array.from(String(12345), Number);