Use Of JavaScript Globals Is Discouraged
Variable declarations should always be made using var to not declare
them as global variables. This avoids conflicts from using a variable name
across different functions as well as conflicts with global variables declared by 3rd party plugins.
Good Example:
function sum(x, y) {
var result = x + y;
return result;
}
Bad Example:
function sum(x, y) {
// missing var declaration, implied global
result = x + y;
return result;
}