Objects in function parameters destructuring in JavaScript

Similarly, you can destructure parameter-objects:

function func({year, month, day}) { console.log(year); // shows 2025 console.log(month); // shows 12 console.log(day); // shows 31 } func({year: 2025, month: 12, day: 31,});

Rework the following code through destructuring according to the theory you learned:

function func(options) { let color = options.color; let width = options.width; let height = options.height; } func( {color: 'red', width: 400, height: 500} );

Rework the following code through destructuring according to the theory you learned:

function func(options) { let width = options.width; let height = options.height; let color; if (options.color !== undefined) { color = options.color; } else { color = 'black'; } } func( {color: 'red', width: 400, height: 500} );
enru