国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

簡介JavaScript中charAt()方法的使用

2019-11-20 12:21:06
字體:
供稿:網(wǎng)友

 這個方法返回從指定索引的字符。

字符串中的字符進(jìn)行索引從左向右。第一個字符的索引是0,并且在一個叫 stringName字符串的最后一個字符的索引是stringName.length- 1。
語法

string.charAt(index);

下面是參數(shù)的詳細(xì)信息:

  •     index: 介于0和1比串的長度以下的整數(shù)。

返回值:

返回從指定索引的字符。
例子:

<html><head><title>JavaScript String charAt() Method</title></head><body><script type="text/javascript">  var str = new String( "This is string" );  document.writeln("str.charAt(0) is:" + str.charAt(0));   document.writeln("<br />str.charAt(1) is:" + str.charAt(1));   document.writeln("<br />str.charAt(2) is:" + str.charAt(2));   document.writeln("<br />str.charAt(3) is:" + str.charAt(3));   document.writeln("<br />str.charAt(4) is:" + str.charAt(4));   document.writeln("<br />str.charAt(5) is:" + str.charAt(5)); </script></body></html>

這將產(chǎn)生以下結(jié)果:

str.charAt(0) is:T str.charAt(1) is:h str.charAt(2) is:i str.charAt(3) is:s str.charAt(4) is: str.charAt(5) is:i 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 汤阴县| 稷山县| 金门县| 霍城县| 寻甸| 太谷县| 镇雄县| 哈巴河县| 濉溪县| 若尔盖县| 时尚| 广宁县| 黄平县| 延津县| 北宁市| 陇西县| 兴山县| 乌兰察布市| 来宾市| 丹寨县| 班玛县| 呼图壁县| 双鸭山市| 红原县| 本溪| 新巴尔虎右旗| 红桥区| 宁河县| 纳雍县| 大新县| 五河县| 嘉义县| 雅江县| 德阳市| 庆云县| 六盘水市| 兴隆县| 乌兰浩特市| 清新县| 旬邑县| 靖边县|