DEV Community

Discussion on: The 10 Component Commandments

Collapse
 
ambroseus profile image
Eugene Samonenko • Edited

also found useful this pattern as more declarative, but need to use it carefully. my early pitfall was to use array.length && ... instead of array.length === 0 && ...

Collapse
 
andrii2019 profile image
andrii2019

What about just using
!!array.length && ...?
It looks smarter and shortly.

Thread Thread
 
ambroseus profile image
Eugene Samonenko

yep, it's shorter :) use !! many years while coding on perl. now I prefer Boolean(array.length)

Collapse
 
andrii2019 profile image
andrii2019

What about just using !!array.length && ... ? It looks smarter and short.

Collapse
 
thewix profile image
TheWix

This is great advice. Falsey and Thruthy values bit me in the same way. I do things like isEmpty(array) or if I am really defensive isNullOrEmpty(array)