![[Javascript]js判断是否为undefined类型 [Javascript]js判断是否为undefined类型](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700)
概述
在项目获取某个元素的值会出现undefined,所以对这种情况要有特殊处理。
可通过下面的代码判断是否为undefined类型。
if (typeof(reValue) == "undefined") {
alert("undefined");
} typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"
总结
发现有那么段时间没大量的使用js了,有些生疏了。看来得抽出点时间,复习一下了。