Skip to content

Instantly share code, notes, and snippets.

@sakshstore
Created August 10, 2023 03:41
Show Gist options
  • Save sakshstore/55d123103488d8283a3c87994e79676a to your computer and use it in GitHub Desktop.
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.
// 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