Created
March 13, 2021 09:00
-
-
Save NovoManu/6477f490402d9d7e249565b07fbed24b 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 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