concat //增加indexOf //查询
1. 增加
基本的类型的方法都不可以改变他原来的值
slice
concat
var str=“hello world”str =str.concat ("good");console.log(str) //hello worldgood
2.查询
// slice// substring 截取某一段// substr 查询并可以输出一部分indexOf 查询字符串值得下标search 查询字符串值得下标 不存在时-1startsWith turn/falsematch //数组的方法 、、 返回匹配的值,是一个数组replacesplit
1.indexOf
可以查询字符串值得下标
console.log(str.indexOf("g")) //11
2.slice ,substring, substr
var str = "hello world";console.log(str.slice(0,3)) // startIndex<=num<endconsole.log(str.substring(0,3)) //helconsole.log(str.substr(0,4)) //hell
3.startsWith search
<script>var str = 'hello world';var http = "https://www.baidu.com"console.log(str.search("e")) //1console.log(http.startsWith("https")) //true</script>
4.match
//数组的方法并非字符串方法
<script>var str = "hello";console.log(str.match("e")) //["e", index: 1, input: "hello", groups: undefined]console.log(str.replace("l","g")) //heglo</script>
