js charAt()

strObj. charAt(index)

strObj

必需。 任何 String 对象或字符串。

index

必需。 所需字符的从零开始的索引。

 

例子1:

   var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

document.write(str.charAt(str.length - 1));

例子2:
console.log("日一二三四五六".charAt(2));



在以下文档模式中受支持:Quirks、Internet Explorer 6 标准模式、Internet Explorer 7 标准模式、Internet Explorer 8 标准模式、Internet Explorer 9 标准模式、Internet Explorer 10 标准模式和 Internet Explorer 11 标准模式。此外,也在应用商店应用(Windows 8 和 Windows Phone 8.1)中受支持。
posted @ 2015-04-29 15:35  椰树飘香  阅读(285)  评论(0编辑  收藏  举报