How to manage the global name space in javascript?

satya - Thu Oct 11 2012 09:48:05 GMT-0400 (Eastern Daylight Time)

How to manage/avoid global variables in javascript?

How to manage/avoid global variables in javascript?

Search for: How to manage/avoid global variables in javascript?

satya - Thu Oct 11 2012 17:02:14 GMT-0400 (Eastern Daylight Time)

Here is my first novice attempt at this


var AKC;
if (!AKC) {
    AKC = {};
}
(function () {

    //Public Interface
    AKC.aspireXmlToJson = aspireXmlToJson1;
    AKC.objectXmlToJson = realXmlToJson1;
    
    // Implementation functions
    function aspireXmlToJson1(mainXmlObjectNode)
    {
        //you can use your $ signs here fine
        var aspireDataSetRootNode 
        = $(mainXmlObjectNode).find("AspireDataSet")[0];
        ....
    } 
    
    function realXmlToJson1(objectNode)
    {
    };
    
    // Private utility functions
    function processCollectionNode(colNode, objArray)
    {
    }
    
    function getNodeType(xmlnode)
    {
    }
    
    function getTextNodeValue(xmlnode)
    {
    }
})();