问题描述
我有以下javascript函数未通过jslint检查
函数hasActiveX(){
return(' ActiveXObject'在窗口中);
}
jslint错误
意外'输入'。与undefined比较,或使用hasOwnProperty方法。
我应该忍受jslint错误,还是有更好的方法来确定ActiveXObject?
我找不到跳过此检查的jslint标志?
我认为JSLint要求您尝试:
function hasActiveX(){
return window.hasOwnProperty('ActiveXObject');
}
或者与undefined进行比较的其他建议:
return(typeof(window.ActiveXObject)!=undefined);
阅读完评论之后,如果JSLint停止抱怨,似乎中的 I have the following javascript function that fails a jslint check jslint error should I just live with the jslint error, or is there a better way to determine ActiveXObject?I could not find a jslint flag to skip this check? I think JSLint is asking you to try: Or the other suggestion of comparing against "undefined": After reading the comments, it seems like 这篇关于jslint错误:意外'在'。与undefined比较,或使用hasOwnProperty的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!实际上是有用的,否则我会尝试上面的选项2。 / p>
function hasActiveX() {
return ('ActiveXObject' in window);
}
Unexpected 'in'. Compare with undefined, or use the hasOwnProperty method instead.
function hasActiveX() {
return window.hasOwnProperty('ActiveXObject');
}
return (typeof(window.ActiveXObject) != "undefined");
in
is actually useful if JSLint would stop complaining about it, otherwise I would try option 2 above.