27 Jan 2009
Tutorial : Namespaces for javascript
Have you ever had a problem using somebody method with the same name. Well, Have you ever thought why javascript don’t have package or namespaces like other languages. Well, change your mind. This is how you will be implementing namespaces for javascript.
if ( com == null || typeof( com ) != "object" ) {
var com = new Object();
}
if ( com.noppanit == null || typeof( com.noppanit ) != "object" ) {
com.noppanit = new Object();
}
com.noppanit = {
message : function()
{
alert('test');
},
message1 : function()
{
alert('test1');
}
};
com.noppanit.message();
com.noppanit.message1();
Til next time,
noppanit
at 00:00