DEV Community

Discussion on: πŸ¦Έβ€β™‚οΈ 11 JavaScript Tips and Tricks to Code Like A Superhero (Vol.2)

Collapse
 
lesleyvdp profile image
Lesley van der Pol • Edited

Love this one too, it's also useful to prevent errors when destructuring something that could be undefined:

const { foo, bar } = couldBeUndefined || {};
Enter fullscreen mode Exit fullscreen mode

This can prevent errors such as "Cannot read foo of undefined".