What is the output of the following? const {a: x, b: y = 10} = {a: 1}; console.log(x, y);

JavaScript Developer Medium

JavaScript Developer — Medium

What is the output of the following? const {a: x, b: y = 10} = {a: 1}; console.log(x, y);

Key points

  • Destructuring assigns values to variables based on object properties
  • Default values can be set using the assignment operator (=)
  • If a property is missing in the object, the default value is used

Ready to go further?

Related questions