class Hash

View source on GitHub →


A set of key/value pairs.

Hash can be thought of as an associative array, binding unique keys to values (which are not necessarily unique), though it can not guarantee consistent order its elements when iterating. Because of the nature of JavaScript, every object is in fact a hash; but Hash adds a number of methods that let you enumerate keys and values, iterate over key/value pairs, merge two hashes together, and much more.

Creating a hash

You can create a Hash either via new Hash() or the convenience alias $H(); there is no difference between them. In either case, you may optionally pass in an object to seed the Hash. If you pass in a Hash, it will be cloned.