Sep 20, 2012

javascript hashtable


var h = new Object(); // or just {}
h['one'] = '';
h['one'] = '';


// show the values stored
for (var k in h) {
// use hasOwnProperty to filter out keys from the Object.prototype
if (h.hasOwnProperty(k)) {
alert('key is: ' + k + ', value is: ' + h[k]);
}
}

No comments:

Post a Comment