I prefer #javascript function declarations over function expressions and...


I prefer #javascript function declarations over function expressions and arrow functions.

Function declaration benefits:

1. Hoisted, so order doesn't matter
2. Visually different than variables, so easy to scan the file
3. Can export default on the same line it's declared on

That said, arrow funcs are great when *inside* a function, since they offer a more concise syntax.

And arrow funcs are handy in classes since they inherit the enclosing scope, and thus, avoid JavaScript's confusing `this` behavior. (But I don't write classes in JS anymore 😎)

View original on X