如何检查JavaScript中的“未定义”?
什么是测试变量是否在JavaScript中未定义的最合适的方法?我看到了几种可能的方法:
if (window.myVariable)
或
if (typeof(myVariable) != "undefined")
if (myVariable) //This throws an error if undefined. Should this be in Try/Catch?
慕工程0101907
弑天下
阿波罗的战车
相关分类