# Object destructuring in JavaScript

You can also destructure objects. Let, for example, we have the following object:

`let obj = { year: 2025, month: 12, day: 31, };`

Let's destructure it:

`let obj = { year: 2025, month: 12, day: 31, }; let {year, month, day} = obj; console.log(year); // shows 2025 console.log(month); // shows 12 console.log(day); // shows 31`

When destructuring objects, variable names must match the keys of the object, the order of variables and elements in the object does not matter

The following code writes parts of an object to the corresponding variables:

`let options = { color: 'red', width: 400, height: 500, }; let color = options.color; let width = options.width; let height = options.height;`

Rework this code through destructuring according to the learned theory.

← →
↑
en ru