This section provides a tutorial example on how JavaScript handles local variables collide with global variables.
To see JavaScript handles global and local variables collide with identical names inside and outside functions,
I wrote the following tutorial example:
This tutorial example tests two sets variables. One set introduced outside the function,
and one set inside the function. Names of variables in one set collide with the other set.
Two "tempVar" declared with "var" statements stay as two variables.
But two "tempNoVar" auto-declared without "var" statements become one variable.
See the output:
Updated value in function:
tempVar = Bird - Updated
tempNoVar = Fish - Updated
After function call:
tempVar = Bird
tempNoVar = Fish - Updated