如何使用下划线检查 javascript 中的“未定义”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15215316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 23:54:02 来源:igfitidea点击:
How do I use underscore to check for "undefined" in javascript?
提问by TIMEX
if(typeof hello! = 'undefined'){
}
This is too hard to type, would like to use underscore
这太难打字了,想用下划线
回答by Platinum Azure
According to the official documentation, you can use _.isUndefined()
:
根据官方文档,您可以使用_.isUndefined()
:
_.isUndefined(window.missingVariable);
=> true
回答by chinabuffet
You mean this? http://underscorejs.org/#isUndefined
你是这个意思? http://underscorejs.org/#isUndefined
_.isUndefined(value)