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

Unlock the program 🚀

Pay once, own it forever.

€79

30-day money-back guarantee

  • 13 modules
  • 113 lessons with full-code examples
  • 29 projects with commented solutions
  • All future lesson and project updates
  • Lifetime access

By submitting this form, you agree to the Terms & Conditions and Privacy Policy.