var x = 0
if you declare that on global, it will be global variable. If you put that on the function it will be local variable
x = 0
if you just simply put this anywhere. If you have declare it on global, var x, then that line would assign the x on global. But the dangerous thing is if you never declare it on global, that line will create global variable x so that this line would assign the global variable that have just been created.
So, to keep the consistency, Use var x = 0 to declare and x = 0 to assign!!