javascript 字符串charAt方法示例
<html>
<head>

  <title>JavaScript String charAt() 方法示例</title>
</head>
<body>
  <script type="text/javascript">

	  var st = new String("Onitroad is great");
	  document.writeln("str.charAt(0) is:" + st.charAt(0));
	  document.writeln("<br />st.charAt(1) is:" + st.charAt(1));
	  document.writeln("<br />st.charAt(2) is:" + st.charAt(2));

	  document.writeln("<br />st.charAt(3) is:" + st.charAt(3));
	  document.writeln("<br />st.charAt(4) is:" + st.charAt(4));
	  document.writeln("<br />st.charAt(5) is:" + st.charAt(5));
	  document.writeln("<br />st.charAt(6) is:" + st.charAt(6));
  </script>
</body>

</html>
javascript 字符串charAt方法

charAt()方法提供指定索引中字符串的字符。charAt()方法将index作为参数,并返回放置在指定索引处的特定字符。如果索引为0,则此方法将返回字符串的第一个字符,依此类推。

日期:2020-04-18 01:09:23 来源:oir作者:oir