MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/30hyan/airbnb_javascript_style_guide_a_mostly_reasonable/cptzlrz/?context=3
r/javascript • u/mrkipling • Mar 27 '15
158 comments sorted by
View all comments
10
Mostly good stuff.
I prefer String(foo) instead of '' + foo.
I think 4 spaces are better than 2.
'collection.length > 0' is perfectly reasonable, there's no need to use shortcuts whenever possible.
I've always used "that" over "_this", but these days this is rarely needed thanks to the fat arrow syntax.
3 u/ianb Mar 27 '15 new String(foo) is such craziness (all boxing is crazy in Javascript), it makes me uncomfortable to see String(foo) 2 u/shriek Mar 28 '15 haha. What about toString()? For the most part I've used that instead of ''+foo 3 u/ianb Mar 28 '15 > (null).toString() TypeError: Cannot read property 'toString' of null 1 u/shriek Mar 29 '15 So is undefined, but I see your point. Thanks for pointing that out.
3
new String(foo) is such craziness (all boxing is crazy in Javascript), it makes me uncomfortable to see String(foo)
new String(foo)
String(foo)
2 u/shriek Mar 28 '15 haha. What about toString()? For the most part I've used that instead of ''+foo 3 u/ianb Mar 28 '15 > (null).toString() TypeError: Cannot read property 'toString' of null 1 u/shriek Mar 29 '15 So is undefined, but I see your point. Thanks for pointing that out.
2
haha. What about toString()? For the most part I've used that instead of ''+foo
toString()
''+foo
3 u/ianb Mar 28 '15 > (null).toString() TypeError: Cannot read property 'toString' of null 1 u/shriek Mar 29 '15 So is undefined, but I see your point. Thanks for pointing that out.
> (null).toString() TypeError: Cannot read property 'toString' of null
1 u/shriek Mar 29 '15 So is undefined, but I see your point. Thanks for pointing that out.
1
So is undefined, but I see your point. Thanks for pointing that out.
undefined
10
u/nawitus Mar 27 '15
Mostly good stuff.
I prefer String(foo) instead of '' + foo.
I think 4 spaces are better than 2.
'collection.length > 0' is perfectly reasonable, there's no need to use shortcuts whenever possible.
I've always used "that" over "_this", but these days this is rarely needed thanks to the fat arrow syntax.