Turn from: http://jsj.52zxw.net/article_view.php/99.html
VBS has a Dictionary object, JS also has the corresponding object, can JS Dictionary object is not cross-browser, so use the array to achieve the function of key value pairs.
Today to write browser-side JS program, you need to use the function of key-value pairs, VBS has dictionary objects, JS should also have a corresponding Dictionary object, check the JS manual, JS really have Dictionary object, program written, cross-browser a test, Found only IE support new ActiveXObject ("Scripting.Dictionary"), other browsers may have compatible writing, support Dictionary objects, online search for a while, did not search, suddenly think of JS Array, looked up some information, Realized I want the function, cross-browser test, Google, Firefox, Opera are compatible, the following is the program code, referring to an online example, slightly modified:
<script type= "Text/javascript" language= "JavaScript"
//Custom Dictionary object
function Dictionary () {
This.data = new Array ();
this.put = function (key,value) {
This.data[key] = value;
this.get = function (key) {
return this.data[key];
this.remove = function (key) {
this.data[key] = null;
this.isempty = function () {
return this.data.length = 0;
this.size = function () {
return this.data.length;
}
//Use example
var d = new Dictionary ();
D.put ("CN", "country");
D.put ("US", "America");
document.write (d. Get ("CN"));
</script>