js判断undefined类型
if (reValue== undefined){
alert("undefined");
}
发现判断不出来,最后查了下资料要用typeof
方法:
if (typeof(reValue) == "undefined") {
alert("undefined");
}
typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"
本文介绍在JavaScript中如何正确地判断一个变量是否为undefined。通过对比使用if(reValue==undefined)与if(typeof(reValue)==undefined)两种方式的区别,强调了typeof方法的重要性,并解释了typeof返回的六种类型。
268

被折叠的 条评论
为什么被折叠?



