-3
我創建了一個名爲myClass
的Javascript類,其中有兩種方法:method1
和method2
。 method1
將值設置爲名爲X
的屬性,method2
將另一個值設置爲相同的屬性併發出警報。Javascript的值不變
問題是我運行的代碼沒有任何警報。 任何想法爲什麼會發生這種情況?
我的代碼如下:
var myClass = function(classParamObject){
this.method1 = function() {
classParamObject.X = 'TEST';
};
this.method2 = function() {
// Even if I change the value of X to 'NEW VALUE', it is not changing
classParamObject.X = 'NEW VALUE';
// This alerts as 'TEST'
alert(classParamObject.X);
};
this.method1();
this.method2();
}
我沒有看到這個詞新的任何地方。除了文字。 –
你是否從某個地方打電話給你的班級? –
三個字母:O_o – jsalonen