JavaScript variables local and global

If a variable is defined in a function then it will be local for this function, it can not be used outside of that function. A variable which is defined outside of the fuction becomes Global and this variable can be used in whole webpage document.


Other examples in Variables (JavaScript tutorial)
Result from the Online TryIt-Editor
chrome 1.0safari 1.0Firefox 1.0ie 3.0opera 4.0