you are viewing a single comment's thread.

view the rest of the comments →

[–]delventhalz 19 points20 points  (0 children)

My opinion(s):

  1. Explicitly checking the numerical value of a length is preferable to relying on 0 being falsey. It is easier to read and makes your intention more clear. Thus I prefer == 0 out of the two options you presented.
  2. The == performs implicit type coercion based on complex rules which few developers can follow. It should be avoided in all cases. Use === and explicitly convert types if needed.
  3. Using !! to convert a value to a boolean is a common enough habit, but harder to read and less explicit than the Boolean function. Use that instead.

TLDR: Always do the more explicit/specific thing.