1. 创建字符串
      1. let str=’123’ let str=”123”
      2. let str=String(123)
    2. 字符串方法

      1. toString——转换成对应进制数

        1. let str = 5
        2. let str2 = str.toString(2)
        3. console.log(str2);
        4. //101
        1. toString(2)—-二进制
        2. toString(8)—-八进制
        3. toString(10)—十进制
        4. toString(16)—十六进制
      2. toLowerCase——-强制转换为小写

        1. let str = "A,B,C"
        2. let str2 = str.toLowerCase()
        3. console.log(str2);
        4. //a,b,c
      3. charAt——-通过下标查找某个字符

        1. let str = "ABC"
        2. let str2 = str.charAt(1)
        3. console.log(str2);
        4. //B
      4. slice——-截取字符串,会生成新字符串

        1. let str = "ABC123"
        2. let str2 = str.slice(1, 3)
        3. console.log(str2);
        4. //BC
        5. //不包括结束位置值
      5. split——以某个字符为分隔符,拆分成一个数组,会生成新数组

        1. let str = "ABC1BNM1OPQ"
        2. let str2 = str.split('1')
        3. console.log(str2);
        4. //['ABC', 'BNM', 'OPQ']
      6. search——-查找某个字符串首次出现的位置

        1. let str = "ABC1BNM1OPQ"
        2. let str2 = str.search('1')
        3. console.log(str2);
        4. //3
      7. indexOf——-与search的区别是无法写正则,search还可以写正则

        1. let str = "ABC1BNM1OPQ"
        2. let str2 = str.indexOf('1')
        3. console.log(str2);
        4. //3
      8. includes——查找字符是否存在,存在返回true,否则返回false

        1. let str = "ABC1BNM1OPQ"
        2. let str2 = str.includes('1')
        3. console.log(str2);
      9. trim——-删除字符串开头空格

        1. let str = " ABC1BN M1OPQ"
        2. let str2 = str.trim()
        3. console.log(str2);
        4. //ABC1BN M1OPQ
    3. 修改字符串

      1. 只能通过重新赋值更改
      2. 通过下标可获取字符,但不能修改
        1. let str = "ABC1BN M1OPQ"
        2. str[0] = 1
        3. console.log(str[0]);
        4. //A