private variables in javascript


 (function(window){
     //private variables
    var name = "test";
   
    var pieAGSI = function(){};

    // get variable
    pieAGSI.prototype.getName = function(){
        return name;
    };
   
    // update variable
    pieAGSI.prototype.setName = function(str){
        name = str;
    };
   
    window.pieAGSI = pieAGSI;
   
})(window);

// test
var test = new pieAGSI();
document.write('<br>test.getName(): ' + test.getName()+"<br>");

评论

此博客中的热门博文

XML, XSL, HTML

Input in element.eleme.io

Data URI是由RFC 2397 ACE