logo

JavaScript Dictionary Object

Thanks to Stephen Neal for YASA (Yet Another SVG Article). Although this one's a tutorial so it's of more use than another "What's SVG?" article.

This morning I got overly-excited when I learnt that there is an IE JavaScript object called Dictionary. After the disappointment of learning that this doesn't mean we can do spell-checks I was still glad to learn of it. Basically it's what Java programmers know as a HashTable and works thus:

var urls = new Dictionary();
urls.add("CodeStore", "http://www.codestore.net");
urls.add("NotesTips", "http://www.notestips.com");

Then we can use it like this:

alert("CodeStore can be found at " + urls('CodeStore') );

The alternative is to use 2D arrays and have to find/know the index of each entry to get at its value. Nice. As well as add() there's exists(), remove(), and removeall()..

About This Page

Written by Jake Howlett on Tue 21 May 2002

Share This Page

# ( ) '

Comments

Commenting is disabled on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content