Boolean.prototype has two methods: toString() returns "true" or "false", and valueOf() returns the primitive. JavaScript calls them implicitly, so true + "X" is "trueX" and true + 1 is 2. Never create a wrapper with new Boolean(): the object is truthy even when it holds false. Boolean(x) without new is the correct converter.
const flag = true;
console.log(flag.toString(), flag.valueOf(), flag + "X", flag + 1);
const wrapped = new Boolean(false); // an object, therefore truthy
console.log(typeof wrapped, wrapped ? "truthy" : "falsy", wrapped.valueOf());
const parseFlag = (s) => String(s).trim().toLowerCase() === "true";
console.log(parseFlag(" TRUE "), parseFlag("false"), Boolean("false"));true true trueX 2 object truthy false true false true
Boolean("false") is true because the string is not empty, so flags from query strings, localStorage and environment variables need a parser like parseFlag(). items.filter(Boolean) drops falsy entries.