Functions declared at the top level of scripts are global; that is, they are always in memory, and all other functions can read and modify them.
You must carefully consider how and where to use global variables because a change to one component of a variable affects all variables that reference the changed variable.