DEV Community

Discussion on: How to define a JavaScript function

Collapse
 
joeattardi profile image
Joe Attardi

I'm not a fan of declaring top-level functions as arrow functions:

const myFn = () => {
  doSomething();
  doSomethingElse();
}

I much prefer the good old fashioned function declaration:

function myFn() {
  doSomething();
  doSomethingElse();
}

Fewer characters isn't always better, I feel the second one is more readable.

Collapse
 
michelc profile image
Michel

I totally agree. That's why I add the (°~°) comment on the hello3 version.
But I hope this post will help me to integrate the new syntaxes.

Collapse
 
joeattardi profile image
Joe Attardi

Oops, I missed that 😂