Skip to content

Instantly share code, notes, and snippets.

@icodesido
Created December 13, 2018 15:51
Show Gist options
  • Save icodesido/f93007f381e58cf132c5b11519ca1323 to your computer and use it in GitHub Desktop.
Save icodesido/f93007f381e58cf132c5b11519ca1323 to your computer and use it in GitHub Desktop.
Complex Object destructuring
var aboutEdward = {
info: ['Edward', 30],
favColor: 'blue',
favSushiRoll: 'Squidy squid squid'
}
function profilePage({favColor} = {favColor: 'vintage pink'}, [name, age] = ['Bunny', 24]) {
console.log(`My name is ${name}. I am ${age} years old and my favorite color is ${favColor}!`)
}
profilePage();
// => My name is Bunny. I am 24 years old and my favorite color is vintage pink!
profilePage({favColor: 'blue'}, ['Ed', 30])
// => My name is Ed. I am 30 years old and my favorite color is blue!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment