How Optional Chaining Can Save You From Unexpected Errors in Javascriptby@smpnjn
1,173 reads

How Optional Chaining Can Save You From Unexpected Errors in Javascript

July 16th 2022
6 min
by @smpnjn 1,173 reads
tldt arrow
Read on Terminal ReaderPrint this storyRead this story w/o Javascript

Too Long; Didn't Read

Optional chaining is a feature in Javascript which lets us access child properties of an object. It's used when properties are optional on an object, so that instead of returning an error, we still get a result from Javascript. If something is given an optional tag, then if it exists, the value will be returned - otherwise it will not throw an error. When to not use optional chaining, you should NOT use it to simply avoid errors. If you overuse it, you will make it more difficult to debug your code later.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - How Optional Chaining Can Save You From Unexpected Errors in Javascript
Johnny Simpson HackerNoon profile picture

@smpnjn

Johnny Simpson

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S EXPERTISE AND PLACE ON THE INTERNET.
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa