今天看到这个这样一段代码
if(cc.charCodeAt(i)>10000&&ss.indexOf(cc.charAt(i))!=-1)
不是很理解,这里判断是不是等于-1有什么意义。布尔值不是只有0和1吗。。
今天看到这个这样一段代码
if(cc.charCodeAt(i)>10000&&ss.indexOf(cc.charAt(i))!=-1)
不是很理解,这里判断是不是等于-1有什么意义。布尔值不是只有0和1吗。。
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
indexOf是按索引找元素的 如果找到该字符,则为 value 的索引位置;否则如果未找到,则为 -1
索引一般是从0开始的 所以-1表示没有找到
在这里 跟布尔值没有关系
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
4 回答2.2k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
3 回答855 阅读✓ 已解决
3 回答1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
indexOf返回所在位置,-1表示没有找到