老师字符串中空格也算一个字符嘛

来源:3-1 String(字符串检索方法)

qq_久坠深海_0

2020-06-14 11:17:56

<!DOCTYPE html>

<html>

<head>

<title>charAt</title>

</head>

<body>

<script>

var str="Hello World";

console.log(str.charAt(5));

// 获取字符串中的值

</script>

</body>

</html>

代码如上。获取索引为5时是不显示的

写回答

1回答

好帮手慕星星

2020-06-14

同学你好,字符串中空格也算一个字符的,所以获取索引为5时是空格,在控制台有结果,但是不显示

http://img.mukewang.com/climg/5ee5a12c09e4468c03520071.jpg

http://img.mukewang.com/climg/5ee5a12709e096c803070064.jpg

祝学习愉快!

0

0 学习 · 40143 问题

查看课程