I'm a little bit confused. Let say I have the following HTML code:
<div id="foo"></div>
And if I write this:
var bar = foo;
console.log(bar);
Then I will get this as output -- Surprisingly, the DOM element with the "foo" ID:
<div id="foo"></div> // Chrome
[object HTMLDivElement] // FireFox
Is there any specific reason for this behavior? or there is something wrong with my set up? Anyone else can reproduce this also? If it's a correct behavior, when and how should we use it?
Update
I see that there is a similar question here, but not all of questions have been answered there. The answers I see there are mostly talking about IE-specific things which is not true -- at least now.