netscape & associative arrays

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • g

    netscape & associative arrays

    Hi,

    I would like to step through all the key-value pairs in an associative
    array. I'm trying:


    for (var i=0 in hashOfItems) { // go through all keys in the hash
    hashOfItems
    // do sth
    }


    which works fine in Internet Explorer but does not seem to be
    recognised in Netscape Navigator. What is the right way to write this?

    Thanks,
    Gina
  • Martin Honnen

    #2
    Re: netscape & associative arrays



    g wrote:
    [color=blue]
    > I would like to step through all the key-value pairs in an associative
    > array. I'm trying:
    >
    >
    > for (var i=0 in hashOfItems) { // go through all keys in the hash
    > hashOfItems
    > // do sth
    > }[/color]

    Why do you want to set i = 0?? Simply do

    for (var key in object) {

    }
    --

    Martin Honnen


    Comment

    Working...