r/javascript • • Mar 31 '17

ES2018 First Look - it changes everything

https://www.youtube.com/watch?v=s-G_RZ4RJLU
464 Upvotes

120 comments sorted by

View all comments

Show parent comments

7

u/azangru Apr 01 '17

Some people dislike anonymous functions (cough — Kyle Simpson — cough)

Some people like function hoisting.

¯_ (ツ) _/¯

0

u/[deleted] Apr 01 '17

[deleted]

1

u/[deleted] Apr 01 '17

Wouldn't that use a function before it is being defined?

1

u/apatheorist Apr 01 '17

As kdesign said, functions are hoisted. And they are also right about the public/private distinction.

What I want to add is that eslint's no-use-before-define rule can be configured to ignore functions:

{
    "no-use-before-define": ["error", { "functions": false }]
}

It's documentation on the matter (emphasis added):

functions (boolean) - The flag which shows whether or not this rule checks function declarations. If this is true, this rule warns every reference to a function before the function declaration. Otherwise, ignores those references. Function declarations are hoisted, so it’s safe. Default is true.