[英]Getting undefined error notice in console even though I'm checking for undefined
This code: 这段代码:
if(typeof(Listings.page_num) != 'undefined') {
// something
}
Triggers this notice in firebug console: 在firebug控制台中触发此通知:
Listings is not defined http://mysite.com/js/content_ads.js Line 13
Well duh, that's why I checked! 嗯,这就是我检查的原因! Is there any way to get rid of this notice?
有没有办法摆脱这个通知?
Do this. 做这个。
var Listings = Listings || {};
if (typeof Listings.page_num !== "undefined") // page_num isset
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.