Skip to content


Subversion checkout URL

You can clone with
Download ZIP
create associative arrays with keys of (almost) any type or primitive in the language
Pull request Compare This branch is 1 commit ahead, 16 commits behind nfeldman:master.
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.




HashTables are associative arrays that can be indexed with almost any type or primitive in the language and some from the environment. Object, Function, Array, RegExp, String, and Number work, as do DOM Elements. Other DOM types haven't been tested yet, nor have JSON objects, but should work. Null, NaN, undefined, Infinity, true, and false are not valid keys.


Released under the terms of the GPL3.0

Public Properties

  • len, the number of keys that exist

Public Methods

  • set, create or update a key
  • get, retrieve a value by key
  • store, stores one or more key:value pairs, if a single parameter is passed it becomes a key with a value of undefined
  • unset, sets a value to undefined but leaves the key
  • del, returns specified key and associated value in an array and deletes them from the object
  • keys, returns a new array of all keys
  • each, iterate over the object and call a user supplied callback on each value
  • flip, swaps keys and values, can optionally flip one key with its value


More Tests

  • in particular, there is a completely untested type-based caching mechanism added entirely on a whim that will maintain an index of the indices of keys of a given type, in theory allowing much faster retrevials from large collections. It is currently configured to kick in once the object contains 500 pairs, if it works at all. I wrote those bits without any testing and there are probably some stupid mistakes I need to fix.

  • performance tests in the major browsers

More Methods

  • add filter, some, and reduce methods

  • consider adding methods to manipulate the keys separately, although this breaks with user expectations for an associative structure

Something went wrong with that request. Please try again.