Possible Duplicate:
Why does !new Boolean(false) equals false in JavaScript?
var b = new Boolean(null);
alert(b instanceof Boolean);
if(b) {
alert('cv');
alert(b.toString());
}
Why if code block is executed? Is b supposed to be a boolean type and evaluated as false?
Please explain thanks
All
objects are truthy, exceptnull. Therefore, even if you writenew Boolean(false)specifically, it will still be truthy.This is why you never write
new Boolean. To cast to a boolean, just use!!