5 Ninja Tips for writing JavaScript as a Pro

1. Stop checking array length using [ ].length > 0.

Noob
Ninja

2. Stop using single if condition, prefer to write it in one single line

Noob
Ninja

3. Stop using if to conditionally add keys in object, prefer de-structuring

Noob
Ninja

4. Stop using too many conditions in if , use includes instead

Noob
Ninja

5. Prefer using boolean result wherever possible using !!

Noob
Ninja

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store