I have a string, and I need to get its first character.(我有一个字符串,我需要获取它的第一个字符。)
var x = 'somestring'; alert(x[0]); //in ie7 returns undefined
What you want is charAt .(您想要的是charAt 。)
charAt
var x = 'some string'; alert(x.charAt(0)); // alerts 's'
1.4m articles
1.4m replys
5 comments
57.0k users