1. concat //增加
  2. indexOf //查询

1. 增加

基本的类型的方法都不可以改变他原来的值
slice
concat

  1. var str=“hello world
  2. str =str.concat ("good");
  3. console.log(str) //hello worldgood

2.查询

  1. // slice
  2. // substring 截取某一段
  3. // substr 查询并可以输出一部分
  4. indexOf 查询字符串值得下标
  5. search 查询字符串值得下标 不存在时-1
  6. startsWith turn/false
  7. match //数组的方法 、、 返回匹配的值,是一个数组
  8. replace
  9. split

1.indexOf

可以查询字符串值得下标

  1. console.log(str.indexOf("g")) //11

2.slice ,substring, substr

  1. var str = "hello world";
  2. console.log(str.slice(0,3)) // startIndex<=num<end
  3. console.log(str.substring(0,3)) //hel
  4. console.log(str.substr(0,4)) //hell

3.startsWith search

  1. <script>
  2. var str = 'hello world';
  3. var http = "https://www.baidu.com"
  4. console.log(str.search("e")) //1
  5. console.log(http.startsWith("https")) //true
  6. </script>

4.match

//数组的方法并非字符串方法

  1. <script>
  2. var str = "hello";
  3. console.log(str.match("e")) //["e", index: 1, input: "hello", groups: undefined]
  4. console.log(str.replace("l","g")) //heglo
  5. </script>