Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of ES2018 Object Destructuring Assignment - Spread Operator
/* < ES2018 */
var catMaru = { name: 'Maru', mittens: true, color: 'tabby' };
var name = catMaru.name;
var coat = {};
coat.mittens = catMaru.mittens;
coat.color = catMaru.color;
/* >= ES2018 */
var catMaru = { name: 'Maru', mittens: true, color: 'tabby' };
var { name, ...coat } = catMaru;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment