Arrow functions in JS
Last updated: September 26, 2023
Introduction
OK. So, it seems as of 2022 or so – the MDN and other documentation is favoring arrow functions for their default examples. We think this is dumb. But what do you think? We’d better talk about it!
Also, it’s not just a syntax choice. The two types of functions do slightly different things in some circumstances.
Function syntax differences
See the Pen HTML cheatsheet 1 / display types by perpetual.education (@perpetual-education) on CodePen.
Arrow functions syntax variations
See the Pen HTML cheatsheet 1 / display types by perpetual.education (@perpetual-education) on CodePen.
Since there are so many options… we think we should just PICK ONE and stick with it.
So, our recommendation is to always use parentheses. Then it’s always the same.