在项目获取某个元素的值会出现undefined,所以对这种情况要有特殊处理。
可通过下面的代码判断是否为undefined类型。
1 if (typeof(reValue) == "undefined") {
2 alert("undefined");
3 }
4
5 typeof 返回的是字符串,有六种可能:"number"、"string"、"boolean"、"object"、"function"、"undefined"
发现有那么段时间没大量的使用js了,有些生疏了。看来得抽出点时间,复习一下了。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2353/viewspace-2800377/ ,如需转载,请注明出处,否则将追究法律责任。