1. Stop checking array length using [ ].length > 0.
2. Stop using single if condition, prefer to write it in one single line
3. Stop using if to conditionally add keys in object, prefer de-structuring
4. Stop using too many conditions in if , use includes instead
5. Prefer using boolean result wherever possible using !!
Disclaimer: Aim of this article is to spread awareness about the concepts, like why
arr.length is sufficient, why we use
!! to get boolean result etc. Off course, I haven’t given reason for the same, it’s up to the reader to do the hard work.
Aim of article is not to look clever in front of others.