[Javascript] Why "true" == true return false?
Can anyone explain me why "true" == true returns false in Javascript?
1 Answer
4 years ago by Jahaan
== returns true only when their value and types are equal. Let's try to print their types as below and understand the difference.
console.log(typeof("true")); // outputs string
console.log(typeof(true)); //outputs boolean
Run here https://onecompiler.com/javascript/3xnphpdxb
As you can see the types of "true" and true are different and hence it returns false.
4 years ago by Meera