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