Junior JavaScript

What is destructuring in JavaScript?

It allows unpacking values from arrays or objects.

Example:

const [a, b] = [1, 2];

const { name, age } = { name: "John", age: 30 };

More from JavaScript Tutorial

All questions for this course