美文网首页
判断字符串中是否包含了参数

判断字符串中是否包含了参数

作者: 一只喵de旅行 | 来源:发表于2020-04-02 12:46 被阅读0次

    includes():是否包含了参数字符串,返回布尔值

    startsWith():参数字符串是否在原字符串的头部,返回布尔值

    endsWith():参数字符串是否在原字符串的尾部,返回布尔值

    例子:

    let breakfast =`1,2,3,4,A,B,C`;

    console.log(breakfast.startsWith('1')) //true

    console.log(breakfast.endsWith('C')) //true

    console.log(breakfast.includes('Z'))  //false

    相关文章

      网友评论

          本文标题:判断字符串中是否包含了参数

          本文链接:https://www.haomeiwen.com/subject/diqxphtx.html