Probably I am confused or something but I am not able to understand this silly scenario.
if("true"){
console.log("Above is true");
}
else{
console.log("Above is false");
}
In the above case the console is nicely printing Above is true
. Which makes total sense. But when I am doing:
if("true" == true){
console.log("Above is true");
}
else{
console.log("Above is false");
}
I am seeing that Above is false
is getting printed in the console.
I am using a loose equality operator here and even after coercion true
will convert to "true"
so it should print Above is true
but is not. What am I missing?