有没有JavaScript中词典的实施? [英] Is there a dictionary implementation in JavaScript?
本文介绍了有没有JavaScript中词典的实施?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能实现与在JavaScript中索引器的阵列?有什么样的净字典?
How can I implement an array with an indexer in JavaScript? Is there something like a dictionary in .Net?
推荐答案
从技术上讲没有,但你可以使用常规的JavaScript对象像一本字典:
Technically not, but you can use a regular JavaScript object like a dictionary:
var a = {"a":"wohoo", 2:"hello2", "d":"hello"};
alert(a["a"]);
alert(a[2]);
alert(a["d"]);
这篇关于有没有JavaScript中词典的实施?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文