What you're saying is that it's only an object because just about
everything's an object and since it looks like a hash, you can be more
specific and call it a hash.
I might agree if this 'hash' object had some functionality in line with
other hash implementations, but exceeded the base functionality of any
run-of-the-mill Object. But it doesn't.
The construct:
{ }
... creates an object.
Fruit.prototype = {
weight: 0,
cost: 0
}
Is the prototype for a Fruit object a hash? Doesn't that mean that with
(x = new Fruit()), x is also a hash? But if that's true, aren't *all*
objects hashes?
No. Of course not.
Of course not. But all objects based on the Object() implement hash
(associative array) data structure, because it appeared to be the most
convenient to keep Identifier : Property/Method pairs.
So yes, if we *really* want to, we can call the OP's code an ugly
object. If it would be the question of life or death to further
identify it, we could say that it's a bastard of HTMLCollection.
Without "life or death" issue I would find some lower level data
construct to describe it. And hash (associative array) is the best for
it. OP's code is still not a fully-qualified object, because it's
missing the most important part: internal methods to react on the world
and on what the world does with it (its data).
They are objects. Objects that are so useful that you can use them much
like you would a hash. But you also use them like arrays. Or strings.
Or integers.
That does not make them hashes. Or arrays. Or strings. Or integers.
Objects are objects.
Sure. And there is not Mr. Christopher J. Hahn, there is an
instantiated human object.
I just amazed. Is it some global trend in CS? When I worked with UC
schools in 90's, the philosophy in CS departments was at the very
bottom of the matter. An average CS student just needed to spell
Aristotle w/o mistake and to know that it was a very smart guy who
lived very long time ago in Europe.
And here I'm really enjoying the most profound developments and
implementations of the eidos theory by Aristotle and by Plato, Gegel's
"all-containing something that became everything", sensualisme by Jung
etc. etc.
Doesn't help to solve little programming proglems raised by Array vs
Hash vs HTMLCollection differences, for this you need to read
<
http://www.geocities.com/schools_ring/ArrayAndHash.html>
(BTW the 3rd edition is coming soon.)
But for a conversation it's really enjoyable.