我按照以下逻辑来检查变量是否已定义:
if (variable==undefined){
////implementation
}
但是发现对于某些情况,它并没有按照预期的方式运行。因此,尝试了这种方法,
if(typeof(variable) == "undefined"){
/////implementation
}
那么哪个是最可靠的?
我按照以下逻辑来检查变量是否已定义:
if (variable==undefined){
////implementation
}
但是发现对于某些情况,它并没有按照预期的方式运行。因此,尝试了这种方法,
if(typeof(variable) == "undefined"){
/////implementation
}