这次给大家带来如何使用js的存储键值,使用js的存储键值的注意事项有哪些,下面就是实战案例,一起来看一下。
重点内容
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="http://cdn.static.runoob.com/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
var map={
key1:'abc',
key2:'def'
};
$(document).ready(function(){
$(button).click(function(){
map.key3=333;//js 里的键必须为字符串
for(var key in map){//可以迭代键
alert(map[key])//依据键取值
}
alert(add value:+map.key3);
});
});
</script>
</head>
<body>
<button>click</button>
</body>
</html>
相信看了本文案例你已经掌握了方法,更多精彩请关注其它相关文章!
推荐阅读:
怎样对webpack模块进行热替换
angular入口组件与声明式组件案例对比
以上就是如何使用js的存储键值的详细内容。