It is said to be a dynamic array because data is added dynamically;
var myarr = new Array();
myarr[0] = 1;
myarr[1] = 2;
myarr[2] = 3;
myarr[3] = 23;
myarr[4] = 11;
Use for to traverse;
It is said to be a dictionary object because it can be accessed in the form of key value:
var dictionary = new Array();
dictionary["Xie Longbao" ] = "xielongbao";
dictionary["Zhou Baocui"] = "zhoubaocui";
dictionary["Xie Xiaoyue"] = "xiexiaoyue";
alert(dictionary["Xie Longbao"]);
alert(dictionary.Xie Longbao);
for (var key in dictionary) {
alert("key:" key "value:" dictionary[key]);
}
Use for-in to traverse. Arrays are a special case of dic. The keys of the array are integers and the keys of dic are strings, so the array can also be traversed using for-in; in addition, because the members of objects in js are also based on keys exists in the form, so we can use for-in to view the members of the js object;
Simplified writing of arrays in js:
var arr = [1, 2, 3, 4];
Simplified writing of dic in js:
var arrdic = { "jim": 30, "tom": 20 };
This is very commonly used in interactions with the server, because now it is passed from the server The data that comes over are all in json format, that is, the key-value pair format in Javascript is convenient for front-end operations;
It is called Stack because it has pop(), push() and other methods to operate the stack;