0 of 8 problems solved • 0%
Use in a course

Array and Object Destructuring

8 exercisesIntermediate

Destructuring pulls values out of arrays and objects into clearly named variables. The pattern mirrors the data’s shape, which keeps repeated property access out of the surrounding code.

const coordinates = [18.07, 59.33]; const [longitude, latitude] = coordinates; const user = { name: "Sam", role: "editor" }; const { name, role: accessLevel } = user; console.log(name, accessLevel); // Sam editor

Practice moves from skipped positions and renamed properties to defaults and destructured function parameters. Destructuring extracts values; it does not copy or update the original collection.