Is it correct to assume that omitting var from a local variable will
ALWAYS override a global of the same name, if it's also missing var?
Also, is there any merit to using var with creative license.
So there's a frame of reference, here is what I discovered
from riddles I created for a previous post.
In Riddle #3,
- omitting the
varfroma = 5overrides itsglobalcounterpart bremains polarized betweenlocalandglobal- the
alert()at the bottom returns 5*5+4+15 - 4 is the
localb. 15 is theglobalb, declared on line 25
In Riddle #2,
- omitting the
varfromb = 4overrides itsglobalcounterpart aremains polarized betweenlocalandglobal- the
alert()at the bottom returns 5*3+4+4 - - 5 is the
locala. 3 is theglobala, declared on line 11
In Riddle #1,
- omitting the
varfrom bothlocalvariables overrides ALLglobalcounterparts - There is no distinction between
localandglobalvariables. - the
alert()at the bottom returns 5*5+4+4 - Only variables declared inside the
functionare recognized