Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#1055 closed defect (fixed)

dojo.lang.isUndefined() fix for really undefined objects

Reported by: [email protected] Owned by: Tom Trenka
Priority: high Milestone:
Component: Core Version: 0.3
Keywords: Cc:
Blocked By: Blocking:


Is there a reason that isUndefined is structured the way it is, such that an undefined variable/object will throw an error.

dojo.lang.isUndefined = function(wh){

return ((wh == undefined)&&(typeof wh == "undefined"));


if you do


with no other reference to foo in your code it'll throw a JS error, becuase JS doesn't like checking for objects that don't exist, rather preferring you to checkf ro properties of existing objects.



will return False as expected.

One idea I had was that if you did:

dojo.lang.isUndefined = function(wh){

return ((typeof wh == "undefined")
(wh == undefined));


That way actual real undefined objects will not fail, but will return false as expected. My logic being that I assume we're testing for two possible states, if the first in the above two is true it won't even try to do the second one (which throws the error) because we're using an OR, but if it doesn't it'll just check the second possible undefined to cover bases.


Change History (4)

comment:1 Changed 16 years ago by dylan

Milestone: 0.4

comment:2 Changed 16 years ago by dylan

Owner: changed from anonymous to Tom Trenka

comment:3 Changed 16 years ago by Tom Trenka

Resolution: fixed
Status: newclosed

(In [5494]) Fixes #1055 by swapping the truth arguments around.

comment:4 Changed 15 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.