//js中的数组可以以键值对的方式存在 var arr = new Array(); arr["A"] = "boss"; arr["B"] = "Emp"; for (var m in arr) { document.write(arr[m] + " "); } var person = new Object(); person["name"] = "xiaoli"; person["age"] = "18"; person["salary"] = "1888.9"; for (var p in person) { document.write(person[p] + "<br>"); } //测试使用有age属性呢? if (typeof person["age"] == "undefined") { document.write("no"); }