Destructuring in assignment

If the name of your variable is the exact same as the property you would extract from an object, you can use destructuring instead. That way, you don’t have to type the same word twice.

const person = {
  name: 'Bob',
  age: 35

// without destructuring
const age = person.age

// with destructuring
const { age } = person

There is more to learn

Get free previews of my upcoming course materials and other bonus content to help you work smarter. I share tips straight to your inbox once a week. You can read previous mails in the newsletter archive.

Cannot show form because cookie consent was not given.