I am a newbie to javascript, so forgive my naiveté here. I have discovered a behavior that appears to be inconsistent, at least to me. In doing some testing I put in the following two lines of code:
console.log(document.getElementById("errorMessage"));
window.alert(document.getElementById("errorMessage"));
I was fully expecting both to give me the same result, but no, I didn't.
console.log(document.getElementById("errorMessage"));
gave me:
<span id="errorMessage">
whereas
window.alert(document.getElementById("errorMessage"));
gave me the alert window with:
[Object HTMLSpanElement]
Can anyone help me understand why I got different results even though I passed the exact same arguments?
Added note: This is not a duplicate question, for the one referenced above asks which is better, and not what is the difference between the two.