Heya all, ive just recently started to get to grips with Javascript NamesSpaces and id thought id share what i know so far with you 
No the bes think about Names Spaces is that you can keep your function/objects organized and clean.
So for exampel if i just set up a website called FaceBox... and within this site i will be using a lot of javascript. what i would do is create a global namespace for all my functions. Example Below
Ok so we have a core name space but i want to add split sections to my NS so its organized.. we can do summat like the following
Ok so we have no define several namespaces but your prob wondering how to add functions etc... well lets create a few functions
Now i hope you can understand why using namespaces is such a good idea.. as you can constantly develope your code by having functions etc...
Also if you are using Dreamweaver Theres a tool installed that helps you write Name Spaces with ease as it shows you all the possible functions within a Namespace
Peace
No the bes think about Names Spaces is that you can keep your function/objects organized and clean.
So for exampel if i just set up a website called FaceBox... and within this site i will be using a lot of javascript. what i would do is create a global namespace for all my functions. Example Below
PHP:
/*Core Javascript File*/
FaceBox = {} /*This is my core namespace*/
Ok so we have a core name space but i want to add split sections to my NS so its organized.. we can do summat like the following
PHP:
/*Core Javascript File*/
FaceBox = {} /*This is my core namespace*/
FaceBox.Tools = {}
FaceBox.GUI = {}
Ok so we have no define several namespaces but your prob wondering how to add functions etc... well lets create a few functions
PHP:
/*Wroking on FaceBox.Tools*/
/*We can define functions within the namespace like so */
FaceBox.Tools = {
Alert : function(message){
alert(message);
}
Redirect : function(loc){
document.location = loc;
}
AlertBeforeRedirect(message,location){
FaceBox.Tools.Alert(message);
FaceBox.Tools.Redirect(loc);
/*Note here you can access the other NS'es like so*/
FaceBox.GUI.ShowDialog('LiteBox');
}
}
/*No we can call the following like so*/
FaceBox.Tools.Alert('Hello World!');
/*Or*/
<a href="#" onclick="javascript:FaceBox.Tools.AlertBeforeRedirect('Your are about to be redirected to the logout page!','logout.php')">Logout</a>
Now i hope you can understand why using namespaces is such a good idea.. as you can constantly develope your code by having functions etc...
Also if you are using Dreamweaver Theres a tool installed that helps you write Name Spaces with ease as it shows you all the possible functions within a Namespace
Peace