top | item 44541647

(no title)

camblomquist | 7 months ago

edit: I'm mostly wrong here.

Because "0" is false. In a logical world, a non-empty string being truthy is fine even if the value is "false". Javascript isn't logical.

discuss

order

wiseowise|7 months ago

``` > if ("0") console.log("true");

true ```

Excuse me?

> In a logical world, a non-empty string being truthy is fine even if the value is "false". Javascript isn't logical.

You must hate our illogical world built on C, because it has the same behavior.

jameshart|7 months ago

Appealing to C - the land of undefined behavior - as a paragon of logic seems like a strange authority to reach for.

camblomquist|7 months ago

I did a `"0" == false` which returned true. I may need another cup of coffee before making claims.