如何在JavaScript中访问数组元素(字符串)中的字母

时间:2015-02-22 05:54:08

标签: javascript

给定一个数组:

var top3Scientists = [ "Hawking", "Newton", "Tesla" ];

如果我输入top3Scientists[1],我会"Newton"。如何访问数组元素的单个字母,即"N"

1 个答案:

答案 0 :(得分:1)

top3Sceintists[1] = "Newton"

然后top3Sceintists[1][0]top3Sceintists[1].getCharAt(0)将为您提供N

工作Fiddle