I am checking for the existence of an object property with a variable holding the property name in question. 我正在檢查是否存在一個對象屬性,其中包含一個保存有問題的屬性名稱的變量。 spa
var myObj; myObj.prop = "exists"; var myProp = "p"+"r"+"o"+"p"; if(myObj.myProp){ alert("yes, i have that property"); };
This is undefined
because it's looking for myObj.myProp
but I want it to check for myObj.prop
這是undefined
由於它正在尋找myObj.myProp
但我但願它檢查myObj.prop
.net