All Objects are Truthy Values
Converting any object into a boolean gives the true value. Here are a few examples.
Boolean({}) //true
Boolean([]) //true
Boolean(new Date()) //true
Even the wrapper object for the false value returns true.
const falseWrapper = new Boolean(false);
Boolean(falseWrapper); //true
All objects are considered to be truthy values. They are evaluated to true in a test condition.
if({}){
console.log('Truthy');
}else {
console.log('Falsy');
}
//'Truthy'
Negating an object using the Not (!...
Published on June 21, 2021 01:02