All posts

Access property off object through destructuring

Pattern matching is a super useful way to cleanup our code. Instead of heaving to access keys directly off of objects in callback functions, we can use destructuring to get access to the key as its own variable from within a closure.

event.locations.filter(({localtionId}) => console.log(locationId)

In the above, instead of having to write location.locationId everywhere in the callback function, we are able to access the locationId directly.


I built two products to help fund continued efforts for this website, it would mean a lot if you would check them out:
1. 2500+ Words for the Undermotivated Software Engineer - A short essay I wrote on the titled topic ($3).
2. Build 3 Chrome Extensions in Under 2 Hours - A course I built to teach chrome extension development ($9-20).