1) Since global variables are dangerous, think that global variable names should be in all the headers so that they are obvious to everyone (including you) who read the code.
2) your first snipp is invalid.
function obj = {
it should be
var obj = {
Additionally, this is actually not a closure. This is how you implement singleton in Javascript.
var mySingleton = (function () { var privateVar = "foo"; function privateFunction() {
I assign the result to a function that I immediately execute for the variable. This function returns an object, so I assign an object to this variable. BUT this object also has private members and private functions.
JustcallmeDrago
source share