# Variables and default values in JavaScript

You can also change the variable names to your own while setting the default values:

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

In the following code, parts of the object are written to the corresponding variables:

`let options = { width: 400, height: 500, }; let с; if (options.с !== undefined) { с = options.color; } else { с = 'black'; } let w = options.width; let h = options.height;`

Rework this code through destructuring according to the learned theory.

←→
↑
en ru