paint-brush
How Optional Chaining Can Save You From Unexpected Errors in Javascriptby@smpnjn
2,076 reads
2,076 reads

How Optional Chaining Can Save You From Unexpected Errors in Javascript

by Johnny Simpson6mJuly 16th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

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
Johnny Simpson

Johnny Simpson

@smpnjn

Product, Engineering, Web

About @smpnjn
LEARN MORE ABOUT @SMPNJN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Johnny Simpson HackerNoon profile picture
Johnny Simpson@smpnjn
Product, Engineering, Web

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite