1.dictionary例子
等同于上面的赋值:
3.push,像数组最后继续添加元素
var dict = new Array(1,4,5,6,7);
dict.push(22,33,22,221);
4,删除元素--只删除元素,但是数组长度 不变,删掉的元素变成undefined
var d = new Array(44, 22, 33, 22, 11, 33);
delete d[0];
<script type="text/javascript" language="javascript">
var dict = new Array();
dict["人"] = "ren";
dict["口"] = "kou";//键值对
dict["手"] = "shou";
alert(dict["口"]); //输出是kou
for (var i in dict) {
alert(i);//遍历dict,输出的是键---人
alert(dict[i]);//遍历dict,输出的是值---ren
}
</script>
等同于上面的赋值:
var dict = { "人": "ren", "口": "kou", "手": "shou" };
3.push,像数组最后继续添加元素
var dict = new Array(1,4,5,6,7);
dict.push(22,33,22,221);
4,删除元素--只删除元素,但是数组长度 不变,删掉的元素变成undefined
var d = new Array(44, 22, 33, 22, 11, 33);
delete d[0];