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' !== '';
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
variable name .It refers to window.name, which is the name of the window.
Also variable document
window.name ,window.document [can't change var name from being window.name, which is a string]
don't use name as a global variable.
Eg
var name = {Name : "dd"};
console.log(name.Name);//Since it's a primitive won't work