javascript - Question regarding static class under namespace -



javascript - Question regarding static class under namespace -

i have namespacein javascript code "mynamespace". creating static javascript class "mychildstaticclass" in it. using modular pattern. below code:

if (typeof mynamespace == 'undefined' || !mynamespace) { var mynamespace = {}; } var mynamespace = (function(mynamespace) { mynamespace.mychildstaticclass = (function() { var myobject; myobject = { x:function(str) { alert(str); } }; homecoming myobject; })(); homecoming mynamespace; } (mynamespace || {}));

the above code used like:

mynamespace.mychildstaticclass.x('test');

and output of above alert box message test. have question way of creating static class , calling methods above? there other ways write in proficient manner?

you same functionality doing:

var mynamespace = {}; mynamespace.mychildstaticclass = { x : function(str) { alert(str); } }

javascript jquery class namespaces

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -