Maybe pretty easy question.
Where should I use var
keyword in JavaScript. It seems to me using it or not have the same effect ( but of course I'm still learning the language )
For instance these both seems the same to me:
(function(){
var a = "mundo"
alert("Hola, " + a )
})()
and
(function(){
a = "mundo"
alert("Hola, " + a )
})()
But of course there must be a more complex example where the difference shows up.