7 ms·
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 l
by camblomquist 1y 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.
- wiseowise 1y 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.
- camblomquist 1y agoI did a `"0" == false` which returned true. I may need another cup of coffee before making claims.
- jameshart 1y agoAppealing to C - the land of undefined behavior - as a paragon of logic seems like a strange authority to reach for.
- wiseowise 1y agoThe point is that this is a well-defined (not pun intended) behavior that exists within C, C++, Python, Ruby and probably a handful more popular languages. This set pretty much constitutes like 70%(?) of mainstream languages. Yet only JS gets shit thrown its way in this thread.