r/JavaScriptTips • • Jun 23 '19

Different ways to write Arrow Functions

Post image
18 Upvotes

4 comments sorted by

2

u/spyninjaman Jun 24 '19

addFive will error

2

u/CrayonConstantinople Jun 24 '19

Yep, replace num1 with num

2

u/ronCYA Jun 23 '19

Wow didn't realise you could omit braces + return! That instantly tidied up some code I'm working on right now, thank you so much.

1

u/prof3ssorSt3v3 Jul 16 '19

Don't forget the two ways to write Arrow functions without a parameter

let f1 = () => 'hello from f1';

let f2 = _ => 'hello from f2';

Second one uses an underscore.