When I run var name = 'jose' !== '';
in my console, it returns "true"
Why does it return "true"
as a string and not true
as a boolean?
I tried it with a different variable name and it returns a boolean.
i.e.: var bobby = 'bob' !== '';
Because name
is window.name
. A special variable that is always a string. Type it into the console of any empty browser and you will get ""
.
You are reassigning its value in your statement.
https://developer.mozilla.org/en-US/docs/Web/API/Window/name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With