Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Referenced to undefined property
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Porter  
View profile  
 More options Aug 25 2007, 7:58 pm
Newsgroups: mozilla.dev.tech.js-engine
From: Mark Porter <dm4m...@gmail.com>
Date: Sat, 25 Aug 2007 23:58:36 -0000
Local: Sat, Aug 25 2007 7:58 pm
Subject: Referenced to undefined property
I am trying to use the FEATURE_WARNING_AS_ERROR flag, and in general
it is helping me avoid common errors. One thing I can't figure out is
this error:

Referenced to undefined property "times" (file:/data/tomcat/webapps/
myna/shared/js/profiler.js#107)

106:       var my = arguments.callee;
107:       if (!my.times) my.times = {}
108:       var curLabel = element.label;

The other common variants cause the same error:
if (my.times === undefined)
if (typeof my.times === 'undefined')

I can get around this with something like this:

if (!my["times"]) my.times = {}

This seems like a hack. Is this the "proper" way to check for the
existence of an object property?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Aug 26 2007, 7:30 am
Newsgroups: mozilla.dev.tech.js-engine
From: Martin Honnen <mahotr...@yahoo.de>
Date: Sun, 26 Aug 2007 13:30:26 +0200
Local: Sun, Aug 26 2007 7:30 am
Subject: Re: Referenced to undefined property

Mark Porter wrote:
> This seems like a hack. Is this the "proper" way to check for the
> existence of an object property?

There is the |in| operator e.g.
   if ("times" in my)

Then there is a method hasOwnProperty
   if (my.hasOwnProperty("times"))

The difference is that |in| finds properties in the prototype chain
while hasOwnProperty does not.

<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Op...>
<URL:http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Gl...>

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Norris Boyd  
View profile  
 More options Aug 26 2007, 3:47 pm
Newsgroups: mozilla.dev.tech.js-engine
From: Norris Boyd <norrisb...@gmail.com>
Date: Sun, 26 Aug 2007 19:47:52 -0000
Local: Sun, Aug 26 2007 3:47 pm
Subject: Re: Referenced to undefined property
On Aug 25, 7:58 pm, Mark Porter <dm4m...@gmail.com> wrote:

On Aug 25, 7:58 pm, Mark Porter <dm4m...@gmail.com> wrote:

This is a bug in Rhino. Here's SpiderMonkey's behavior:

js> if (o.foo) print(3)
js> if (o.foo == "undefined") print(3)
typein:4: strict warning: reference to undefined property o.foo
js> if (typeof o.foo == "undefined") print(3)
3

So a reference to an undefined property in strict mode is okay as the
operand of typeof or in a conditional.

I've filed bug https://bugzilla.mozilla.org/show_bug.cgi?id=393785.

--N


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Norris Boyd  
View profile  
 More options Aug 31 2007, 4:53 pm
Newsgroups: mozilla.dev.tech.js-engine
From: Norris Boyd <norrisb...@gmail.com>
Date: Fri, 31 Aug 2007 20:53:53 -0000
Local: Fri, Aug 31 2007 4:53 pm
Subject: Re: Referenced to undefined property

I just checked in changes to CVS so this is now fixed. Rhino now
suppresses warnings for undefined property o.p for the following
constructs:

typeof o.p
if (o.p)
if (!o.p)
if (o.p == undefined)
if (undefined == o.p)

--N


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Porter  
View profile  
 More options Sep 1 2007, 5:38 pm
Newsgroups: mozilla.dev.tech.js-engine
From: Mark Porter <dm4m...@gmail.com>
Date: Sat, 01 Sep 2007 21:38:03 -0000
Local: Sat, Sep 1 2007 5:38 pm
Subject: Re: Referenced to undefined property
On Aug 31, 2:53 pm, Norris Boyd <norrisb...@gmail.com> wrote:

That will be perfect. Will that be in 1.6R8 when it is released? Also,
will "if (o.p === undefined)" work as well?

I'm ashamed to admit that I'm currently suppressing  this error by
using a indexOf() on the error message, and I look forward to removing
that hack.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »