Re:JavaScript: The Curious Case of null >= 0
by jmfayard on Saturday September 09, 2017 @01:19PM
(#15208009)
Booleans having only three values would be an improvement for JavaScript where they actually have four : true, false, null and undefined
[ Parent
| on HN ]
Re:JavaScript: The Curious Case of null >= 0
by moefh on Saturday September 09, 2017 @02:02PM
(#15208277)
This is nonsense. If typeof(x) is 'boolean', then x is either true or false.
Now, if you don't know the type of x and try to use it as boolean without being careful, it might look like it has four values. That comes partly from being dynamically typed and partly from performing coercion instead of throwing errors. So one might argue that Javascript encourages people to write code that's not careful, or that it's very clumsy to write careful code in Javascript, but saying booleans have four values is just nonsense.
Re:JavaScript: The Curious Case of null >= 0
by catnaroek on Saturday September 09, 2017 @05:04PM
(#15209150)
It's perfectly okay for a Boolean algebra to have four values. The two extra values can't behave the way JavaScript's “null” and “undefined” do, though.
No three-valued Boolean algebra exists.