admin管理员组文章数量:1326036
Using Firefox, working on a Firefox extension, I continually get a javascript warning:
reference to undefined property mySidebar.contextProgress
I have tried multiple ways of testing the value:
if (mySidebar.contextProgress === undefined) {
And
if (typeof mySidebar.contextProgress == "undefined") {
And
if (!mySidebar.contextProgress) {
And
if (mySidebar.contextProgress == undefined) {
However the error console in Firefox continues to give me the warning on the same line every time, the line in question is the line that I posted the code from above. The actual check for the value is causing the warning.
I also put an alert to check the value of mySidebar.context, which is always an object, so it is not from the parent that I'm getting the warning.
Any ideas?
Using Firefox, working on a Firefox extension, I continually get a javascript warning:
reference to undefined property mySidebar.contextProgress
I have tried multiple ways of testing the value:
if (mySidebar.contextProgress === undefined) {
And
if (typeof mySidebar.contextProgress == "undefined") {
And
if (!mySidebar.contextProgress) {
And
if (mySidebar.contextProgress == undefined) {
However the error console in Firefox continues to give me the warning on the same line every time, the line in question is the line that I posted the code from above. The actual check for the value is causing the warning.
I also put an alert to check the value of mySidebar.context, which is always an object, so it is not from the parent that I'm getting the warning.
Any ideas?
Share Improve this question asked Sep 24, 2010 at 16:54 PurgePurge 6474 silver badges12 bronze badges 1-
You could also just set it to
null
at browser startup. – Tyler Commented Sep 25, 2010 at 3:17
2 Answers
Reset to default 6As Swingley said, you can use Object.prototype.hasOwnProperty() to check for existence of a direct property on an object. This won't work for properties inherited from the prototype chain, however. For both situations, inherited and direct, you can use the in operator:
if ("netProgress" in mySidebar.context) {
Try object.hasOwnProperty()
if (mySidebar.context.hasOwnProperty("netProgress")) {
本文标签: firefoxjavascript reference to undefined propertyStack Overflow
版权声明:本文标题:firefox - javascript reference to undefined property - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742119304a2421620.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论