I read in the book of Stoyan Stefanov about one var template. It is also good JSLint.
But I noticed in my code that I can overload this template. It looks like my whole .js file, a complete script, is just one big var.
For instance:
$(function(){
var
some_var1 = 'some_value',
some_var2 = { },
tiny_fun = function(){ },
tiny_fun2 = function(){ },
Constructor1 = function(){ },
Constructor2 = function(){ },
script_body = (function(){
var c1 = new Constructor1();
c1.some_method();
})();
});
This is bad? maybe I misunderstood this single-var pattern and should use it only for variables - to prevent the use of global variables?
source
share