javascript lookup-hash implemented as object

Javascript syntax is rich and confusing. Better get the underlying idea before you try to memorize the syntax.

There's no builtin construct to get the length of an associative array, since it's an object.

http://nfriedly.com/techblog/2009/06/advanced-javascript-objects-arrays-and-array-like-objects/

Everything in javascript is an object. Everything. Arrays, functions, even numbers! Because of this, you can do some really interesting things, such as modifying the prototypes of Objects, Arrays, etc

Javascript arrays are a type of object used for storing multiple values in a single variable. Each value gets numeric index and may be any data type.

http://docstore.mik.ua/orelly/webprog/jscript/ch08_06.htm OReilly's javascript book:

JavaScript objects are much more like Perl hashes than C++ or Java objects.

http://www.quirksmode.org/js/associative.html

In JavaScript, objects are also associative arrays (or hashes). That is, the property

theStatus.Home

can also be read or written by calling

theStatus['Home']

Thus, you can access each property by entering the name of the property as a string into this array. Such an array associates each key with a value (in this case the key Home is associated with the value normal). In the Perl programming language it is also called a hash.

Unlike **Perl**, which requires you to create such an associative array explicitly, JavaScript automatically creates a associative array for each object.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s