js中哈希表的几种用法总结
2018-10-12 13:53
344 查看
1.
<html>
<head>
<script type="text/javascript">
// by Go_Rush(脚本之家) from //www.jb51.net/var hash={
"百度" :"http://www.baidu.com/",
"Google" :"http://www.google.com/",
"微软" :"http://www.microsoft.com/",
"脚本之家" :"//www.jb51.net/"
};function showUrl(element){ //使用哈稀对象
alert(hash[element.value])
}
</script></head>
<body>
<form>
<input type="text" id="txt" />
<input type="button" value="测试" onclick="showUrl(document.getElementById('txt'));"/>
</form>
</body>
</html>
2.
<script>
var ht =
{
"c1" : {"UserID":"userc1","UserName":"usercc1"},
"c2" : {"UserID":"userc2","UserName":"usercc2"},
"c3" : {"UserID":"userc3","UserName":"usercc3"}
};
alert(ht["c1"]["UserID"]);
alert(ht["c2"]["UserID"]);
</script>
3
<script>
var Arr =new Array({'s':'sss','aa':'www'},{'s1':'wwww','aa1':'ssss'});
alert(Arr[0].s);
alert(Arr[0].aa);
alert(Arr[1].s1);
alert(Arr[1].aa1);
</script>
您可能感兴趣的文章:
相关文章推荐
- js中哈希表的几种用法总结
- js中哈希表的几种用法总结
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js jquery ajax的几种用法总结(及优缺点介绍)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- 为您解惑:js中继承的几种用法总结(apply,call,prototype).........
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js jquery ajax的几种用法总结(及优缺点介绍)
- [转载]js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)
- js中继承的几种用法总结(apply,call,prototype)