Thomas 'PointedEars' Lahn said:
rh said:
Grant said:
John G Harris wrote:
It's the other way round. Every ECMAScript object is an associative
array.
No, every ECMAScript object is an object that can have properties which can be
accessed using dot notation (theObject.theProperty), or "array" notation
(theObject[theProperty]).
The original statement is correct. The accessor syntax, while being
important, doesn't change the fundamental (logical) nature of the
object.
The fundamental (logical) nature of any object is not to be an "associative
array" (whatever that might be) but to be an object having properties and
methods, encapsulating data.
As described earlier in this thread, an associative array is a
well-defined mapping of keys to values. In computing, they are an
abstract data type, which means they are defined by the operations
they support, rather than in terms of their underlying implementation.
They can also be considered to be a form of generalization of an array
which supports only integers as indexes.
Only because ECMAScript is a loosely typed
language where properties can be added and removed during runtime and those
of type "function" are considered methods of the object, does not make an
object per se an array.
No, but it does mean that an objects ECMAScript are conceptually based
on associative arrays. The keys are "property names" and the values
are scalars or other objects, such as functions. And while some
language implementations may have confined associative array values to
being scalars, and/or all values must be of the same type, there's
nothing inherent in the concept of associative arrays that requires
such constraints to prevail.
Since dynamic addition and removal of keys/values is fundamental to
associative array operation, and you recognize the fact that
ECMAScript supports such for objects, you're simply lending
confirmation to the contention that ECMAScript objects are in fact,
fundamentally, associative arrays.
../rh