DEV Community

Discussion on: Destructuring an object

Collapse
tabithakavyu profile image
Thabitha Kavyu Author

Using the rest operator ..., you can store all remaining properties from the original object to a variable.

   const { name, ...rest}= Baby;
   console.log(rest); // 
  {favColor: "Tabby", Age: 21}