a = 'A';
b = null;
const w = a === b;
const x = a && a.length;
const y = b && b.length;
const z = (a && a.length) || (b && b.length);
const u = (a && a.length) && (b && b.length);
console.log(typeof w); // boolean
console.log(typeof x); // number
console.log(typeof y); // object
console.log(typeof z); // number
console.log(typeof u); // object
I was expecting all of them to be boolean! Can you please help me understand why some of them are not boolean ?
It is not obvious to me why short-circuit evaluation results in different z and u types.