Skip to content

Instantly share code, notes, and snippets.

@frontsideair
Created March 2, 2017 07:51
Show Gist options
  • Save frontsideair/8baf46d0b431b6aa0d5fb5fe49b12700 to your computer and use it in GitHub Desktop.
Save frontsideair/8baf46d0b431b6aa0d5fb5fe49b12700 to your computer and use it in GitHub Desktop.
Objects and closures are (in some ways) the same thing! (Illustrated in ES6)
const obj = { foo: 'bar', baz: 'quux' } // let's define our object
const { foo, baz } = bar // the keys are now in the envorinment!
const hello = 'world' // hello is defined in our environment
const newObj = { hello } // and now it's captured in our object!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment