concept Hash object in category javascript

appears as: Hash object, The Hash object
Prototype and Scriptaculous in Action

This is an excerpt from Manning's book Prototype and Scriptaculous in Action.

When writing our own Ajax call, we had to manually encode and create a querystring (see in listing 1.2). Here, we’re using Prototype’s $H() function (yes, these guys like short names!) to create a Hash object out of an ordinary JavaScript object . We’ll look at Hashes in more detail in chapter 10; for now, suffice it to say that Hash has a predefined toQueryString() method that will create our parameters for us. The syntax may look a little odd at first, especially if you don’t realize that $H() is just a JavaScript function, but once you get it, it saves a lot of trouble in remembering to call encodeURI() every time you create a querystring.

10.5.1. Using the Hash object

The Hash object provides a set of additional functionality for objects that work like associative arrays. Like the Enumerable object that we saw in section 10.4, Hash is a free-floating set of functions that can be mapped onto a variety of objects. In Ruby terminology, it is a mixin.

Hash introduces a much smaller group of functions than Enumerable. Let’s look at each of them in turn. But first, we’ll see how to create a Hash object.