1、增加 concat()
<script>var str = "hello";var b = "world";var res = str.concat(b);console.log(res);</script>
2、查询
2.1、indexOf(value) 根据值查找对应的下标 找不到返回-1
<script>//可以查询某个字符的下标(下标从0开始)var str = "hello";console.log(str.indexOf("1")); -1表示没有</script>
2.2、search(value) 根据值查找对应的下标 找不到返回-1
<script>var str = "helloworld";var res = str.search("r");console.log(res); //7console.log(str.search("a")); //-1</script>
2.3、slice(startIndex,endIndex) 不包含最后一位
<script>var str = "hello";console.log(str.slice(1,4));</script>
2.4、includes 是否包含某位(多位)字符 返回boolean
<script>var test = "hello world";console.log(test.includes("world"));</script>
2.5、substr(index,length) 从哪里开始获取多少位
<script>var str = "hellodakhlaui";console.log(str.substr(1,4));</script>
2.6、substring(startIndex,endIndex) 不包含结束下标
开始下标
结束下标
<script>var str = "hello";var res = str.substring(1,4); //ellconsole.log(res);</script>
2.7、match(value) 返回匹配的字符串,返回的是数组
存在返回数组
不存在返回null
<script>//返回的是一个数组,将匹配的字符返回一个数组var str = "你好你来你的"var res = str.match("你");console.log(res); //["你"]console.log(str.match("它")); //null</script>
3、其他
3.1、replace( ) 替换字符串
<script>var str = "你好";console.log(str.replace("你","它")); //它好var s = "hello";console.log(s.replace("l","*"));//he*lo</script>
3.2、split( ) 将字符串分割成字符串数组
<script>//将字符串分割为数组var str = "hello";console.log(str.split());console.log(str.split(""));console.log(str.split("e"));</script>
