r/javascript • • Mar 09 '15

Things every JavaScript developer should know

http://ilikekillnerds.com/2015/03/things-every-javascript-developer-should-know/
326 Upvotes

118 comments sorted by

View all comments

Show parent comments

1

u/zoeshadow Mar 09 '15

Fat arrow functions lexically bind this value, so it is more predictable for people coming from other languages.

When you have window as a this value it doesn't help anyone, it's clearly not intended, and depending in the caller of the function to call it correctly is risky

0

u/[deleted] Mar 09 '15 edited Mar 09 '15

I completely agree, which is more reason to avoid to my above mentioned list.

I can understand why that would make ES6 more desirable, but not why so many developers on here sound as if they cannot live without it. How can people not live without it if these features are less than a year old in the browser and ES6 is not even finished yet?

2

u/zoeshadow Mar 09 '15

It's hard to explain, but for me is all about familiarity, my first language was Java, and I also use Java on the server. So when I write this I expect it to be something. Using ES6 short function syntax I can write safer code. I could write Javascript without using this but is not a real alternative when you use most of the real world frameworks.

And the short syntax helps to improve readability and reusability of functions!

3

u/MrBester Mar 09 '15

See, that's a problem. It's all very nice having these short forms, but readability for those used to a different language is not a valid reason for having them. Does Spanish add arbitrary constructs to make it easier for English speakers?