r/node • • Nov 10 '20

Conditionally call a function with optional chaining.

Post image
345 Upvotes

126 comments sorted by

View all comments

1

u/Not_Sugden Nov 10 '20

the 2nd approach looks more funky, personally i'd do

if (typeof myFunction === 'function') myFunction();