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.

--

--

राहुल मिश्रा
राहुल मिश्रा

Responses (18)