什么是关联数组?在计算机科学中,关联数组(Associative Array),又称映射(Map)、字典(Dictionary)是一个抽象的数据结构,它包含着类似于(键,值)的有序对。这里介绍如何根据键去寻找值。
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<script type ="text/javascript">
var anthony = new Array();
anthony["color"] = "blue";
anthony["food"] = "duck";
document.write("anthony favoutire color is " +anthony["color"] +"<br/>");
document.write("anthony favoutire food is " +anthony["food"]);
</script>
</body>
</html>