JavaScript基础教程

文章39 |   阅读 11552 |   点赞0

来源:https://blog.csdn.net/u011541946/category_6887610.html

JavaScript学习笔记33-关联数组

x33g5p2x  于2022-03-06 转载在 其他  
字(0.7k)|赞(0)|评价(0)|浏览(271)

什么是关联数组?在计算机科学中,关联数组(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>

相关文章