Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数组,如下所示。当我输入 3 时,它应该显示“三”,或者如果我输入 1,它应该显示“一”。
var v1 = new Array("('one', '1)", "('Two', '2')", "('Three', '3)");
您可以使用 JavaScript 对象文字:
var v1 = { 1: 'one', 2: 'two', 3: 'three' }; alert(v1['1']); // one
小提琴