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

20

u/ajacksified Apr 01 '17

() => 'welcome to the future'

7

u/azangru Apr 01 '17

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

Some people like function hoisting.

¯_ (ツ) _/¯

6

u/[deleted] Apr 01 '17

If we're just writing a normal, ordinary function, what benefit does

const myFunction = () => { doStuff; }

have over

function myFunction() { doStuff; }

assuming the function doesn't invoke this?

To put it another way - other than using shiny new features for the sake of using shiny new features (which is, honestly, the sort of thing I would do), why change how you write ordinary functions?

1

u/prium Apr 02 '17

I really like it when passing functions as arguments.

objectArray.map(object => object.property);

vs

objectArray.map(function(object) {
  return object.property;
});

Declaring functions with arrows just seems silly though.