How to declare global variables when using the strict mode pragma

IMO alternative 3 is best. But it assumes that window represents the global scope – which is true for the browser but not for other JS environments (command line, Node.js, etc.).

The following will work across the board:

(function(globals){
  "use strict";
  globals.GLOB = {};
}(this));

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)