标签: javascript
给定一个数组:
var top3Scientists = [ "Hawking", "Newton", "Tesla" ];
如果我输入top3Scientists[1],我会"Newton"。如何访问数组元素的单个字母,即"N"?
top3Scientists[1]
"Newton"
"N"
答案 0 :(得分:1)
top3Sceintists[1] = "Newton"
然后top3Sceintists[1][0]或top3Sceintists[1].getCharAt(0)将为您提供N
top3Sceintists[1][0]
top3Sceintists[1].getCharAt(0)
N
工作Fiddle