zoukankan      html  css  js  c++  java
  • ES6字符串模板

    (1)字符串模板

    let foo='string'

    let bar =`这是一个字符串${foo}`

    conso.log(bar) //这是一个字符串string

    (2)字符串查找

    includes方法==>bar中是否含有foo这个字符串,有则返回true,没有则返回false

    console.log(bar.includes(foo)) //ture

    startswith方法==>bar是否以foo这个字符串开头,有则返回true,没有则返回false

    console.log(bar.startsWith(foo)) //false

    endsWith方法==>ar是否以foo这个字符串结尾,有则返回true,没有则返回false

    console.log(bar.endsWith(foo)) //true

    (3)复制字符串

    repeat方法==>将某个字符串复制多少个 .repeat(复制的个数)

    let foo='string'

    console.log(bar.repeat(5)) //stringstringstringstringstring

  • 相关阅读:
    acm常见错误-持续更新
    学习之旅
    快速幂
    写个管理自我的小工具
    Tree构建
    Sql server学习
    asp.net webAPI学习
    AngularJS数据双向绑定
    虚拟机学习
    wps学习
  • 原文地址:https://www.cnblogs.com/sunyang-001/p/10840533.html
Copyright © 2011-2022 走看看