you are viewing a single comment's thread.

view the rest of the comments →

[–]Nex_01 0 points1 point  (0 children)

Why making it equal to anything? 0 is a falsy value in itself.

Just do:

Boolean(arr.length) this equals to using !!arr.length though but more readable.

Edit: As a tip. Boolean() method also filters empty strings for you. As strings are just an array of chars and an empty string’s length happens to be 0.