我有一个案例,我检查变量是否未定义。在某些情况下,我想再次变量undefined,以便它返回undefined?这会被视为不良做法吗?
:D /代码示例!
if (loc1 == undefined){
loc1 = loc.title
}
else if(loc2 == undefined){
loc2 = loc.title
}
else{
//here I want loc1 and loc2 to turn undefined again!
}
答案 0 :(得分:3)
你可以这样做:
var test = 1;
test = undefined;