What does the following code output, and what concept does it illustrate? const obj = { a: 1, b: 2, c: 3 }; const { a, …rest } = obj; console.log(rest);

JavaScript Professional Hard

JavaScript Professional — Hard

What does the following code output, and what concept does it illustrate? const obj = { a: 1, b: 2, c: 3 }; const { a, …rest } = obj; console.log(rest);

Key points

  • Rest object gathers remaining properties
  • Destructuring assigns specific properties
  • Helps simplify code and access object properties
  • Only collects own enumerable properties
  • Useful for extracting specific values from objects

Ready to go further?

Related questions