美文网首页
3、字符串模板``(1前边的那个键)

3、字符串模板``(1前边的那个键)

作者: 海晏河清_富贵荣华 | 来源:发表于2020-06-07 11:24 被阅读0次
    字符串模板``
    • 1、字符串连接 ``可随意换行
    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