MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/javascript/comments/bidtu1/7_useful_javascript_tricks/em20u4t/?context=3
r/javascript • u/xxammuxx • Apr 28 '19
36 comments sorted by
View all comments
8
This is a pretty worthless comment, but if you were code golfing...
['', 123, 0, 'foo'].filter(Boolean) ['', 123, 0, 'foo'].filter(x=>!!x)
...the latter is one less character.
6 u/s1dd Apr 29 '19 This works too:['', 123, 0, 'foo'].filter(x=>x)
6
This works too:
['', 123, 0, 'foo'].filter(x=>x)
8
u/DGCA Apr 29 '19
This is a pretty worthless comment, but if you were code golfing...
...the latter is one less character.