Do all 3 ways use the same conversion to bool?
function check(variable){
let b1 = Boolean(variable);
let b2 = !!variable;
let b3 = variable ? true : false;
return b1 === b2 && b2 === b3;
}
Do all 3 ways use the same conversion to bool?
Yes. The Boolean function, the logical NOT operator and the conditional operator all convert the value to a boolean value via the internal ToBoolean algorithm:
(of course engines are free to implement it however they want, but it has to behave like the spec dictates)
MDN Web Docs tell us the following:
Do not use a Boolean object to convert a non-boolean value to a boolean value. To perform this task, instead, use Boolean as a function, or a double NOT operator:
const x = Boolean(expression); // use this...
const x = !!(expression); // ...or this
const x = new Boolean(expression); // don't use this!
According to the docs, the first form is equivalent to the second form and looking at the second form, you could deduce that it is equivalent to the third form you suggested.
So all three of your ways should be equivalent and they are dependent on what JavaScript considers as a truthy value
As to why you shouldn't use new Boolean() to convert something to boolean, this section offers a bit of an explanation. TL;DR You might accidentally initialize non-truthy values as truthy.