var str="I'm a big big girl。In a big big world"; str.indexOf("big")( )。
时间: 2024-04-27 22:24:46 浏览: 22
字符串 "I'm a big big girl。In a big big world" 中第一次出现子字符串 "big" 的位置是从索引 7 开始的,因为它是第一个 "big"。所以,str.indexOf("big") 的值为 7。需要注意的是,indexOf 方法区分大小写。如果要查找不区分大小写的所有匹配项,可以使用正则表达式或 toLowerCase() 方法。
相关问题
var str="a big big world"; str.indexOf("big")( )。 str.lastIndexOf("big")( )。 str.indexOf("hello")( )。
在字符串 "a big big world" 中,第一次出现子字符串 "big" 的位置是从索引 2 开始的,因为它是第一个 "big"。所以,str.indexOf("big") 的值为 2。
最后一次出现子字符串 "big" 的位置是从索引 6 开始的,因为它是最后一个 "big"。所以,str.lastIndexOf("big") 的值为 6。
子字符串 "hello" 在字符串 "a big big world" 中没有出现过,所以 str.indexOf("hello") 的值为 -1。
var str=”wu@gmail.com” var num=str.indexOf(“.”) console.log(num)输出num的值
根据给出的代码,变量`str`中存储的是一个字符串"wu@gmail.com",变量`num`通过调用字符串的`indexOf()`方法获取字符串中第一个"."出现的位置,并将其赋值给`num`变量。调用`console.log()`方法输出`num`的值,代码如下:
```
var str = "wu@gmail.com";
var num = str.indexOf(".");
console.log(num); // 输出:8
```
因为"."在字符串中的位置是第9个字符,而`indexOf()`方法返回的是从0开始计数的索引值,所以输出的结果为8。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)