I don't think you've read the docs or the specs carefully. There's a difference between the Boolean constructed object and the function. The function performs type conversion.
const testBoolean = Boolean(""); // used function, not object constructor
testBoolean ? console.log("true") : console.log("false"); // => "false"
So not only are you down voting me for pointing out a place where Boolean object instantiation behaves differently than expected but you claim that I didn't read the docs, then you show a completely different usage pattern that works as intended. The point is that the Boolean object behaves in unpredictable manners depending on implementation, and for new developers that are prone to making simple mistakes, like using 'new' when they shouldn't, they should stick to the simpler methods instead, such as using !! for booleans.
The Boolean function works as intended, and if browsers are following the ES specification, then there's a definition for both the object and function. Otherwise, whatever browser version you're talking about has not implemented ecmascript. You say that Boolean() behaves unpredictably based on implementation. What browser version are you talking about?
This "usage pattern" (using the function) is the prescribed one by the Mozilla docs, and the Mozilla docs distinguishes between the object constructor and the function. As does the specs. It works exactly as intended. You're the one who insists on framing the discussion around the Boolean object constructor.
The !! pattern is worse than the Boolean function because type conversion should be done explicitly and without extraneous effects. The reason why people do double-negation is because they only wanted type conversion, but the ! operator converts type and negates.
You seem to be reading too much into it. Try to read that first code example in the MDN again. It uses the new operator. Wouldn't that be confusing to a new developer looking for examples? I think so.
0
u/[deleted] Jun 22 '16
[deleted]