3、字符串模板``(1前边的那个键)
作者:
沈念一 | 来源:发表于
2020-06-07 11:24 被阅读0次字符串模板``
let name="Tom"
let age = 18
let str = `这个人叫${name},
年龄${age}
`
- 2、includes str.includes("要查找内容") = true/false
let str = 'apple banana2 orange';
str.includes(banana) //true
//判断浏览器
navigator.userAgent.includes('chrome')
- 3、str.startswith("开头") 字符串是否以谁开头
- str.endswith("结尾") 字符串是否以谁结尾
- str.repeat(number) str重复number次
- str.padStart(整个字符串长度,填充内容) 往前填充
- str.padEnd(整个字符串长度,填充内容) 往后填充
本文标题:3、字符串模板``(1前边的那个键)
本文链接:https://www.haomeiwen.com/subject/litctktx.html
网友评论