+ 4
What's happening?
I write below code in javascript code playground. var a = 1; name = (a == 1); console.log(typeof name); It shows String How? Variable name should be set with true boolean. Please explain me. why it's happening?
3 Answers
+ 7
Your problem is that 'name' is already a variable outside of your code. It's referencing the property of the global object 'Window.' Basically, you're messing with 'Window.name' in your code, and it's a string variable.
+ 4
Yes Jakob Marley. You are right.
+ 2
is it allowed to do that kind of comparison when defining a variable?
I don't know if that's the case, but I think its worth checking out.