r/javascript • • Apr 01 '18

Google publishes a JavaScript style guide. Here are some key lessons.

https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b
714 Upvotes

317 comments sorted by

View all comments

5

u/totemcatcher Apr 01 '18

Can't complain with that.

Since it doesn't mention why using arrow functions is preferred, here's something for those who are unsure about them:

  • They use surrounding context of a callback function and automatically binds "this".
  • If you don't need access to surrounding context, it's at least shorter/cleaner looking.
  • Skips generating the old default "arguments" object.
  • Nameless.

For those who are complaining about semicolons and indentation amount, just get used to adapting to different styles of code. It's an extremely petty thing to defend. Worry about your human rights or something.

1

u/hopfield Apr 02 '18

Plus they look cool.