number to array code example

Example 1: convert array to number

let x = [1,2,3,4,5]
let num = +x.join("")

Example 2: convert number to array javascript

const numToSeparate = 12345;

const arrayOfDigits = Array.from(String(numToSeparate), Number);

console.log(arrayOfDigits);   //[1,2,3,4,5]

Example 3: integer to array javascript

Array.from(String(12345), Number);

Example 4: number to array javascript

const n = 123456;
Array.from(n.toString()).map(Number);
// [1, 2, 3, 4, 5, 6]

Example 5: number to array js

const arrayOfDigits = numToSeparate.toString().split("");

Tags:

Java Example