HomeProjectsArticlesNotesAbout

Object Destructuring

javascript
notes

Object destructuring the method of extracting properties at

The problem it solves

Examples

Without destructuring

const car = {
  color: 'blue',
  model: 'ford',
  make: 'mustange'
  year: '1976'
}

const color = car.color
const year = car.year

With desctructuring

const car = {
  color: 'blue',
  model: 'ford',
  make: 'mustange'
  year: '1976'
}

const {color, model, make year} = car

console.log(color)
// blue

Renaming In Destructure

const car = {
  color: 'blue',
  model: 'ford',
  make: 'mustange'
  year: '1976'
}

const { color: c, model: mo, make: ma, year: yr} = car

console.log(mo)
// ford
;(() => {
  // do stuff
})()

References

Dead simple intro to destructuring javascript

More Articles

All Articles

Links

Home Articles Notes Projects About Style Guide Site Credits

Contact

ย connect@dev.lucaszapico.space

Location

๐ŸŒŽ Earth