Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of ES6 Object Destructuring Assignment
/* ES5 */
var catMaru = { name: 'Maru', mittens: true, likes: 'boxes' };
var name = catMaru.name;
var mittens = catMaru.mittens;
var likes = catMaru.likes;
/* >= ES6 */
var catMaru = { name: 'Maru', mittens: true, likes: 'boxes' };
var { name, mittens, likes } = catMaru;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment