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

3

u/Disgruntled__Goat Apr 01 '17

Why? I was under the impression no one uses function at all now.

2

u/inu-no-policemen Apr 01 '17
function foo() {...}

is much nicer than:

const foo = () => {...};

ESLint and TypeScript's compiler will complain about redeclaring functions. So, there really is no benefit whatsoever in practice. The const option is longer, less easy to scan, and you have to pseudo-declare your functions in the right order.

The only benefit is that it shows newbies that JS has first-class functions. I.e. that you can assign them to variables. Personally, I really don't care for that. First-class aren't that special anymore.

I'll always prefer the declarative option over an imperative one.

1

u/Disgruntled__Goat Apr 01 '17

The only benefit is that it shows newbies that JS has first-class functions. I.e. that you can assign them to variables.

You don't need the short function syntax for that.

const foo = function() { ... };

2

u/inu-no-policemen Apr 01 '17

Meant that it's the only benefit of using an assignment instead of a declaration.