简体   繁体   English

在控制台中获取未定义的错误通知,即使我正在检查未定义

[英]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.

相关问题 即使我的 package.json 和 node_modules 文件夹中有它们,我也得到了未定义的包 - I'm getting undefined packages even though I have them in my package.json and node_modules folder 我已经在jQuery中收到函数未定义错误,即使该函数已定义 - I am getting function undefined error in jQuery, even though the function is defined 即使我定义了一个字符串,我也收到了一个错误,即使我定义了一个字符串,我也收到了一个错误 - I'm getting an error even though I defined a string and I'm getting an error even though I defined a string 即使已定义也变得未定义(JavaScript) - Getting undefined even though it is defined ( JavaScript ) 为什么即使我在 javascript 中使用可选链接 (?.) 检查,我也会得到“undefined has no properties”? - Why do I get "undefined has no properties" even though I am checking with Optional chaining (?.) in javascript? 即使声明了变量,也出现未定义的错误 - Undefined error even though variable is declared Javascript 变量未定义,即使我可以在屏幕上看到我试图捕获的值 - Javascript variable undefined even though I can see the value I'm trying to capture on the screen .map()未定义,即使我传递了数组 - .map() undefined even though I pass an array 即使我刚刚使用它,FB仍未定义 - FB is undefined even though I just used it 未定义 Function 即使我在 Javascript 中定义了它 - Undefined Function Even though I defined it in Javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM