// declare a hash table var myTable = new Array(); // add new items to the table myTable['key1'] = 'hello'; myTable['key2'] = 'world'; myTable['key3'] = ' world.'; // remove a item from the table delete myTable['key2'];
A expert on system architect with full SDLC and Agile development experience. Skills: , C# C++ Scrum OOA/OOD javascript ASP.Net MVC XML, HTML Web Service, RESTful, WCF, Android and etc. Email me if you need help on development.
Friday, 9 September 2011
Hash Table or Key/Value pair Array in JavaScript
Key/Value or hash table sometimes is very handy and helpful on implementing your business logic. In .Net world, I use a lot of Dictionary<TKey, TValue> collection object. How to do the same thing using Javascript is bit a tricky to me as I spent most of my time in the past using Microsoft C++ and C# developing server-side system. Google it a bit and here is my working solution including of declaration, insertion and deletion of items.
Labels:
javascript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment