The Hash that prototype declares provides associative array functionality, like 
returning of keys and values, stuff that Object doesn't provide on it's own. 
It's intent is to act like an associative array, where Object is intended to be 
used as an Object.

Contrary to my previous understanding, the Hash functions do not handle values 
with type function. They still get copied around, but aren't visible from any 
of the hash functions like values() or keys().

My apologies for any confusion I may have caused out there.

Cheers


P.S: If what I've said has confused you, try this example and see for yourself.

var h1 = { a: 1, b: 2 };
var h2 = { c: 3, d: function() { alert('d exists'); } };
var mergedHsh = $H(h1).merge(h2);

mergedHsh.d();
alert(mergedHsh.inspect());

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Sam
Sent: Monday, July 10, 2006 10:51 AM
To: rails-spinoffs@lists.rubyonrails.org
Subject: RE: [Rails-spinoffs] prototype hash method


Sam wrote:
> Is it easy to explain the difference between a hash
>  
> var myHash = {a: 'value for a'}
>  
> and an object
>  
> var myObject = {a: 'value for a'}

There is no difference between those. They are both associative arrays
(hashes).
---------------------------------------------------

Since prototype.js has Object and Hash methods, maybe my question should
have been something like:  "What is the reasoning behind why prototype
offers different properties and methods for Hash and Object types?"

Sam





_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to