Skip to content

Instantly share code, notes, and snippets.

@NovoManu
Created March 13, 2021 09:00
Show Gist options
  • Save NovoManu/6477f490402d9d7e249565b07fbed24b to your computer and use it in GitHub Desktop.
Save NovoManu/6477f490402d9d7e249565b07fbed24b to your computer and use it in GitHub Desktop.
const arr = ['Hello', 'World']
const [hello, world] = arr
console.log(`${hello} ${world}`) // Expected output: Hello World
const obj = { h: 'Hello', w: 'World', again: 'Again' }
const { again, w, h } = obj
console.log(`${h} ${w} ${again}`) // Expected output: Hello World Again
// It's possible to rename object keys
const { h: hello1, w: world1 } = obj
console.log(`${hello1} ${world1}`) // Expected output: Hello World
// Extracted deep nested property
const nested = { a: { b: { c: 'Nested property' }}}
const { a: { b: { c }}} = nested
console.log(c) // Expected output: Nested property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment