Current Size:
Chakra BreakPoints
base0px
sm480px
md768px
lg992px
xl1280px
2xl1536px
Current Height:Width
widthpx
heightpx

Subjects

Object Destructuring

Date Created: 2018/03/15 14:19:17

Last Update: 2021/10/04 09:27:43

#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 Notes

All Notes
HomeProjects

Links

Home Articles Notes Projects About Style Guide Site Credits

Contact

 [email protected]

Location

🌎 Earth