Most Powerful Open Source ERP

Guideline Use Of JavaScript Globals Is Discouraged

Better never declare any globals anyway.
  • Last Update:2017-04-05
  • Version:001
  • Language:en

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;
}