如何组合2个变量torso和comb来正确访问数组中的字符串
var comb = new Array("MT 1.1","MT 1.2","MT 1.3","MT 1.4","MT 1.5","MT 1.6","MT 1.7","MT 1.8","MT 1.9","MT 2","MT 2.1","MT 2.2");
var torso = 2;
var num = comb[+torso+];
答案 0 :(得分:3)
使用torso
变量作为索引来访问comb
数组中的项目:
var num = comb[torso];
2
的值为torso
,num
将包含数组中的第三项; "MT 1.3"
。