ES6字符串扩展

<!--
1. includes(str) : 判断是否包含指定的字符串

     let str = 'abcdefg';
    console.log(str.includes('a'));//true
    console.log(str.includes('h'));//false


2. startsWith(str) : 判断是否以指定字符串开头

    console.log(str.startsWith('a'));//true
    console.log(str.startsWith('d'));//false


3. endsWith(str) : 判断是否以指定字符串结尾

   console.log(str.endsWith('g'));//true
    console.log(str.endsWith('d'));//false


4. repeat(count) : 重复指定次数

   console.log(str.repeat(5));

 

posted @ 2019-12-09 17:32  distant-遥远  阅读(178)  评论(0编辑  收藏  举报