Created
August 10, 2023 03:41
-
-
Save sakshstore/55d123103488d8283a3c87994e79676a to your computer and use it in GitHub Desktop.
Destructuring assignment unpacks values from arrays or properties from objects into distinct variables, making it easier to work with complex data structures.
This file contains hidden or 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
// Longhand | |
const person = { firstName: 'John', lastName: 'Doe' }; | |
const firstName = person.firstName; | |
const lastName = person.lastName; | |
// Shorthand | |
const person = { firstName: 'John', lastName: 'Doe' }; | |
const { firstName, lastName } = person; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment