JavaScript Object as a Dictionary

[Apr 16, 2011]


You can create a dictionary by writing...

var myDictionary = {};

Then you add an object to this dictionary with key & value pair...

myDictionary["key"] = "value";

Check if we already has an object with specific key in the dictionary...

if ("key" in myDictionary) { /* do something */ }

Remove object with specific key from the dictionary...

delete myDictionary["key"];

Advanced Web Applications With Object-Oriented JavaScript

Checking if an associative array key exists in Javascript

How do I remove objects from a javascript associative array


Home
Web Log
Contact Me
© 2008-2012 Khomsan Phongphisansakun
May 19th, 2012