In this blog, I have shared 5 awesome shorthand tricks to make a developer's life faster!
1) Setting the variables values
Normally you would defi...
For further actions, you may consider blocking this person and/or reporting abuse
Beware when using the double NOT - it isn't the same as
Math.floor
:Thanks for pointing. agree.π
I see people often complaining about that these kind of shorthands decrease code readability but wtf, I love write compact code like this and also love to read it like this. If someone complain about it is because he/she is not adapted to use the beneficts of write compact code using the new Ecma features. Maybe all the community need is more post like these showing how easy is to get those tips, so π good post π
Thank you so much glad you liked it. enjoyπ₯
If shorthand isn't understandable to the next dev that follows you, it probably ought not to be done. For example, #2 using -- as Math.floor. Besides, it fails in some cases, so it may cause future problems. #4 is iffy on the readability, but I do like it.
That's why you should read the doc carefully before using anything that prevents breaking. Glad you liked it Thank you for reading.π
ES2020 and 2021 have brought some more awesome "shortcuts", namely optional chaining which allows you to shorten
to
another neat one from 2021 (currently available through babel plugin) is logical assignments,
||=
,&&=
,??=
.in the case of
&&=
you can shortenAlso, instead of
let fruits of fruits
it should belet fruit of fruits
since in that for loop, you're working with just one of the fruits (or items) in the list at the time.Oh, Thank you so much I really missed that. Thank you for your point I'm changing it immediately.
You seem to forget that code is an order of magnitude read more than it is written. Optimize for readability and leave those things for optimizing tools and bundlers.
If you are developing alone and you know how these all work then in my case it is ok. But your right code must be Optimize for readability I agree.π
It was great. Thanks
Glad you liked it. enjoy.π₯
Excellent, and I appreciate the brevity. I would love more of these.
Thank you so much glad you liked it! I will try my best to keep making these. enjoy.π₯