javascript如何判断一个变量未定义
文章目录
undefined
永远不要直接使用undefined进行变量判断;
使用typeof和字符串'undefined'对变量进行判断。
// not good
if (person === undefined) {
...
}
// good
if (typeof person === 'undefined') {
...
}
摘自腾讯的代码规范文档
http://alloyteam.github.io/CodeGuide/index.html
http://alloyteam.github.io/Co...

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论