Skip to content

Instantly share code, notes, and snippets.

@theRemix
Created July 19, 2018 01:50
Show Gist options
  • Save theRemix/d729865f7473fda668d431be9ed910de to your computer and use it in GitHub Desktop.
Save theRemix/d729865f7473fda668d431be9ed910de to your computer and use it in GitHub Desktop.
Nested Destructuring Styles
const data = {
cat : {
dog : {
bird : {
mouse : "squeek"
}
}
}
};
const say1 = input => {
console.log('say1 mouse', input.cat.dog.bird.mouse );
}
const say2 = ({ cat : { dog : { bird : { mouse }}}}) => {
console.log('say2 mouse', mouse );
}
const say3 = input => {
const { cat : { dog : { bird : { mouse }}}} = input;
console.log('say3 mouse', mouse );
}
say1( data );
say2( data );
say3( data );
@theRemix
Copy link
Author

output :

say1 mouse squeek
say2 mouse squeek
say3 mouse squeek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment