1.正常字符串我们使用单引号,双引号来
2.注意转义字符 \
序号 | 代表字符 |
---|---|
\0 | Null字符(\u0000) |
\b | 退格符(\u0008) |
\t | 水平制表符(\u0009) |
\n | 换行符(\u000A) |
\v | 垂直制表符(\u000B) |
\f | 换页符(\u000C) |
\r | 回车符(\u000D) |
\" | 双引号(\u0022) |
\' | 撇号或单引号(\u0027) |
\\ | 反斜杠(\u005C) |
\u4e2d | Unicode字符串 \uxxxx |
\x41 | ASCII字符 |
3. 多行字符串编写
let msg = `
hhell
world
buduijin`
4.模板字符串
let a = 'a';
let b = 'b';
let c = `${a}${b}c`
console.log(c)
5.字符串长度
6. 字符串的可变性,不可变
7.大小写转换
student.toUpperCase()
student.toLowerCase()
8. student.indexOf(‘t’)
9. substring
student.substring(1) //从第一个字符截取到最后一个字符
student.substring(1,3) //截取[1,3)