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

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

ms access - C# - Using OleDbParameter on table name -