Created
October 8, 2015 01:29
-
-
Save AsaAyers/46f2a408e8f40d194e3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const someObject = { | |
a: "Some Value" | |
// ^ Input | |
// ^ Output: someObject.a | |
} | |
const { a: a } = someObject | |
// ^ Output: `const a` | |
// ^ Input: someObject.a | |
// When the key and value are the same you can just use one: | |
const b = 'B' | |
const nextObject = { b } | |
// ^ Input/Output: `nextObject = { b: b }` | |
console.assert(nextObject.b === b) // true | |
// LOOK! I can create a new scope to avoid declaring the same variable twice! | |
{ | |
const { b } = someObject | |
// ^ Input/Output: `const b = someObject.b` | |
console.assert(b === nextObject.b) | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment