å¨Javascriptä¸ï¼è®¿é®ç§ææåçæåæ¹æ³å¯ä»¥åå¨ç±»çååä¸
æä¸ä¸ªPersonç±»ï¼æ¥ænameè¿ä¸ç§æå±æ§ã
// Javascript code:
var Person = (function () {
var name;
var P = function (theName) {
name = theName;
this.getName = function () {
return name;
};
};
P.prototype.setName = function (newName) {
name = newName;
};
return P;
}());
å¨ä»¥ä¸ä»£ç ä¸nameåæäºéæç§æåéèä¸æ¯æåç§æåéã è½ç¶å¯ä»¥å建éæåå
¸ï¼ä½æ¯ä»£ç çå¯è¯»æ§ä¼éä½ã
温馨提示:内容为网友见解,仅供参考