Can someone please explain JavaScript Truthy and Falsy, using the below sample data. I have read other threads but still confused.
var a = 0;
var a = 10 ==
In JavaScript, &&
and ||
don't always produce a boolean value. Both operators always return the value of one of their operand expressions. Using the double negation !!
or the Boolean
function, "truthy" and "falsy" values can be converted to proper booleans.
true && true =>
true
true && false =>
false
true && 'rahul626'=>
"rahul626"
true && 'i am testing Truthy' && ' upvote it'=>
" upvote it"
Try, tried on console
Well described here