2013-03-05 62 views

回答

0

你可以嘗試

var tmpNum:Number = Number(this.format.size); 
this.format.size = Object(tmpNum--); 

!但是,爲什麼不使用:

this.format.size--; 
0

this.format.size爲空或未定義或尺寸不格式的屬性(即this.format爲null)

1

第一:你在哪裏創建格式變量?

二:行

this.format.size = Object(Number(this.format.size)--); 

沒有意義。當遞減用作後綴運算符時,表達式的值在處理後綴運算符之前返回。 用途:

format.size -= 1; 

format.size--; 
0

演員/轉換號是難辭其咎。 ---= 1的簡寫。所以它需要一些東西來存儲新的價值。但數量轉換返回一個值,而不是一個參考,所以你寫什麼有翻譯爲:

//let's say this.format.size holds the value '5' 
this.format.size = Object(5 -= 1); 

而且你不能在一個值的值存儲明顯。

如果你不是100%肯定this.format.size返回一個數字那麼簡單的出路是:

this.format.size = parseInt(this.format.size) -1; 

但很明顯,這將是更好的驗證被存儲格式的值。規模前期。

相關問題