更多“試一試”的例子。
定義和用法
該charAt()方法返回一個字符串指定索引處的字符。
第一個字符的索引是0,第二個字符為1,等等。
提示:在一個字符串的最後一個字符的索引是字符串 。長度-1,倒數第二個字符的字符串是。長度-2,依此類推(請參閱“更多示例”)。
瀏覽器支持
方法 | |||||
---|---|---|---|---|---|
charAt() | 是 | 是 | 是 | 是 | 是 |
句法
string.charAt( index )
參數值
Parameter | Description |
---|---|
index | Required. An integer representing the index of the character you want to return |
技術細節
返回值: | 一個字符串,表示指定索引,或者一個空字符串的字符,如果指數未找到 |
---|---|
JavaScript的版本: | 1.0 |

更多示例
