javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Prefer function expression instead of function declaration?

Open jirutka opened this issue 10 years ago • 1 comments

Both have pros and cons. Function expression leads to better consistency (you cannot use function declaration for function composition, currying etc.), but it’s not hoisted (so it requires specific ordering of functions). Also you cannot write export default const foo = () => { }, but I consider this as insignificant.

jirutka avatar Jan 20 '16 14:01 jirutka

I think I am willing to give up some consistency in favor of preventing some WTF moments caused by hoisting. My personal opinion: top-level function keyword helps me with code readability.

Let's keep this open in case someone else wants to chime in.

jnv avatar Jan 26 '17 13:01 jnv