Opened 10 years ago

Closed 10 years ago

#9487 closed defect (invalid)

dojo.isArray() fails on undefined object properties

Reported by: theduke Owned by: anonymous
Priority: high Milestone: tbd
Component: General Version: 1.3.1
Keywords: base isArray Cc:
Blocked By: Blocking:

Description

The summary pretty much says it all.

Example:

var o = { a:'string', b: {} };

dojo.isArray(o.a); returns the string itself dojo.isArray(o.blabla) returns nothing, neither true nor false

Change History (4)

comment:1 Changed 10 years ago by Sam Foster

returning nothing == false (though !== false). if you are calling dojo.isArray in a boolean context it behaves correctly. ie.

  if(dojo.isArray(o.notthere)) { .. }

Undefined is not an array. Testing an defined object property returns a boolean for me. I cant get it to give the wrong answer. Do you have a case where

 Boolean( dojo.isArray(..) ) 

..would be incorrect?

comment:2 Changed 10 years ago by Adam Peller

we could just add a "!!" to the result instead of returning something truthy/falsey, but none of the other Crockford functions do. I think we're satisfying what the docs say this function does.

comment:3 Changed 10 years ago by bill

Yah, I would close as wontfix/invalid. I know some people feel strongly claiming that truthy/falsey values are bad but seems fine to me.

comment:4 Changed 10 years ago by Eugene Lazutkin

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.