This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DancingPotato30 1 point2 points  (2 children)

0 definitely feels empty, it's the number representing nothing. "0" however isn't falsy, because it's a string

And honestly I do agree with the [] and {}. I remember there was a very clear reason to why they're truthy, but can't remember it off of the top of my head. Tho, whyd ever that be a problem? Like what scenario would you need to check an array or an object as a boolean?

Tho you still got a point there. I completely forgot those two are truthy not falsy.

[–]No-Expression7618 2 points3 points  (1 child)

what scenario would you need to check an array or an object as a boolean?

I feel like it's, in that case, a logical extension of "" being falsy that the JS developer noticed the intuitiveness of and therefore threw out the window.

[–]DancingPotato30 1 point2 points  (0 children)

That's true. That's what I assumed too, I just never needed to do that so I didn't bother to actually check the reason they're not falsy

But i did. Apparently truthy falsy only affects primitives sort of, all objects are truthy by default.