2012-01-17 142 views

回答

4

你將不得不迭代在對象鍵,並檢查每一個的值

for(var p in x) { 
    if(x[p] === 0) { 
     console.log("Found!"); 
    } 
} 

根據您是否在意可能從prototype繼承的屬性,您可以添加hasOwnProperty檢查在那裏:

for(var p in x) { 
    if(x.hasOwnProperty(p)) { 
     if(x[p] === 0) { 
      //Found it! 
     } 
    } 
} 
+0

非常感謝你................:d:d – 2012-01-17 08:34:41

+1

沒問題,很高興我能幫助:) – 2012-01-17 08:36:06

0

我在ActionScript中編程,這是一個類似的方言,所以我幾乎可以肯定它會是相同的。請嘗試:

if(arr[0] != null) 

注意,有arr[0]arr["0"]之間的差異

相關問題