MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/node/comments/jrau9t/conditionally_call_a_function_with_optional/gbswdnp/?context=3
r/node • u/wobsoriano • Nov 10 '20
126 comments sorted by
View all comments
1
I often used something like this:
const xs = //something from an api const ys = mapFun ? xs.map(x => mapFun(x)) : xs;
where mapFun is passed as an argument but it maybe not passed at all
1
u/[deleted] Nov 10 '20
I often used something like this:
const xs = //something from an api const ys = mapFun ? xs.map(x => mapFun(x)) : xs;
where mapFun is passed as an argument but it maybe not passed at all