Forum Moderators: open

Message Too Old, No Replies

# of values in arrays

         

ccy1234

1:10 am on Sep 6, 2005 (gmt 0)

10+ Year Member



How do I find the number of values in an array?

thanks.

Bernard Marx

7:33 am on Sep 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The simple answer is that it's held in the array's
[blue]length[/blue]
property.

The first complication comes when you consider that an array may have undefined values. Then you consider that JS arrays are really little more than collections of name/value pairs. It is possible for arrays to have non-contiguous, non-integer, or negative indices, or indices that aren't numbers.

All told, the solution depends very much on the exact nature of the question.

DrDoc

8:34 am on Sep 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When all else fails -- you can always loop through it and use a vanilla counting method
:-¦