In article <1102633747.076556.123190@z14g2000cwz.googlegroups .com>,
Robert <rccharles@my-deja.com> writes[color=blue]
>I am curious why some people feel that Javascript doesn't have
>associative arrays.[/color]
One reason is that there are two meanings and no-one knows which is
being used. 'Associative array' can describe a very general kind of
storage unit, just as 'stack' can be a very general description.
Alternatively, 'associative array' can be a particular data type
supplied as part of a computer language. You can get some lovely
never-ending arguments if people are using these different meanings.
[color=blue]
>I got these definitions of associative arrays via
>goggle:
>
>Arrays in which the indices may be numbers or strings, not just
>sequential integers in a fixed range.
>
http://www.sunsite.ualberta.ca/Docum...r/gawk_20.html
>
>(n.) A collection of data (an array) where individual items can be
>indexed (accessed) by a string, rather than by an integer as is common
>in most programming languages.
>docs.sun.com/db/doc/805-4368/6j450e60a
>
>(n.) A collection of data (an array) where individual items may be
>indexed (accessed) by a string, rather than by an integer as is common
>in most programming languages.
>
www.npac.syr.edu/nse/hpccgloss/hpccgloss.html[/color]
Back in the 60s when people were discussing hardware associative arrays
the 'address', or key, or index, was just a bit pattern supplied by the
user. The user might think it was ASCII characters or a floating point
number or whatever, but the hardware couldn't care less.
When an associative array is implemented in software the 'address' has
to be a defined type so the compiler/interpreter knows how to allocate
the right amount of storage when creating a cell, but it still isn't
restricted to integers and strings.
[color=blue]
>Another name for a dictionary.
>academics.tjhsst.edu/compsci/thinkCS/chap19/node11.html[/color]
A dictionary is a particular kind of associative array. The 'address' is
a word; the value is a chunk of text.
But then people have used 'dictionary' in a more general way. 'Map' is
another popular name.
[color=blue]
>My goggle search:
>
http://www.google.com/search?hl=en&l...ociative+Array
>
>
>It seems to me that both javascript arrays and object meet these
>definitions.
>
>One problem with Javascript would be the extra indexes automatically
>created but you can check for them if you need too.
>Maybe I am missing something.[/color]
True. Both Object objects and Array objects have their good points and
their bad points if your javascript application needs to implement an
associative array.
John
--
John Harris