javascript complaining 

why does everybody do `let f = x => x+1` now instead of `function (x) { return x+1 }`? function-keyword functions can be declared in any order, which is so much nicer than having to carefully declare everything in the correct order.
Follow

re: javascript complaining 

@hack `let` statements can also be written in any order so long as the statement has executed by the time the function is actually called

re: javascript complaining 

@Lady true but that feels so messy. it could be the functional programming talking but i really don't like it when definition order is coupled to execution order

re: javascript complaining 

@hack in idiomatic JS, typically functions are defined at the top level (often imported from another module) and only ever called from within other functions, with the entrypoint usually being a file which depends on all the others

in this case, the definition order and execution order are effectively decoupled (and necessarily, since module load order is undefined)—all the top-level declarations which define constants will have executed before the main entrypoint executes.

you're right that you can't do, like

```
main();
const main = () => blah();
```

whereas you can with functions. but this would go against best-practices either way. best-practices would be

```
import main from "./main.js";
main();
```

and in that situation definition and execution order are decoupled by nature of the module system

(as for why people use arrow functions now instead of the other ones, that's a different conversation but the short answer is people find them easier to write and conceptually simpler)

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.