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.