Variables in javascript vs namespacing -



Variables in javascript vs namespacing -

what's downside of using object properties variables in javascript? not add together level of namespacing (effectively)?

var myprop = something;

vs

var myobj = {}; myobj.myprop = something;

actually it's mutual wrap code in 'modules' , utilize objects sort of namespacing. example:

var foomodule = (function(){ var private = 3; var privatemethod = function(){}; var exports = {}; exports.foo = function(){ alert("i public! private is: " + private); } homecoming exports }); alert(private); // throws error foomodule.foo(); //works

javascript variables properties

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -