Destructure Array Elements in JavaScript

JavaScript·2 min read·Jan 1, 2026

The destructuring assignment syntax is a shorthand syntax that allows you to extract values from arrays, in order, and assign them to variables in a more concise and structured way:

let [element1, ..., elementN] = array;

Note: When destructuring a property that doesn't exist within the object, the specified variable will hold the undefined value.

Example

Let's consider this script, that outputs the result of a division and its remainder:

const divide = (a, b) => [a / b, a % b];const [result, remainder] = divide(7, 3);console.log('result = ', result);console.log('remainder = ', remainder);

When executed, it will extract the values of the array returned by the divide() function into two distinct variables named result and remainder, and output their values.

Which will produce this output:

result =  2.3333333333333335remainder =  1