False compare with false
If both boolean value is same then it true but if different then return false.
Look at basic example of Boolean Value
First we declare an variable x using let keyword and assign a false value to it.
let x = false;
Now create an another variable y and assign boolean value using new Boolean().
let y = new Boolean(false);
Finally we compare this two value and also with typed equal.
console.log(x == y); console.log(x === y);
Any idea what should be the output of above code statement.
let x = false; let y = new Boolean(false); console.log(x == y); // output => 🧐 ? console.log(x === y); // output => 🧐 ? // Made with ❤️, by @jsstartup
Now you know the answer is true, false. But why doesn’t both of them should give the same output because both are false. Let me explain.
So, it true both value is false that’s why it return a true.
But if you can see that y is a boolean object created using new Boolean(). Whose data type is an object. But x value is false whose data type is Boolean.
At last, That’s why we get an answer “true, false“.
Let me know in the comment section, what you think about it.
I hope you understand the concept and logic behind it.
But wait, i have something more for you –
- JS Quiz – effect of misplaced semicolon after if statement
- JS Quiz – what does triple value compare 10 > 9 > 8 return
And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page
If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.