ES 之 05. Es6新增字符串函数

.startWith()
.endWith()
.includes()
.repeat()

string.startsWith(searchvalue, start)

let str='abcdefgh'
str.startsWith('a')//true
str.startsWith('ab')//true
str.startsWith('bc',1)//true  大小写敏感

str.endsWith("g",7) //true

const str1 = 'Cats are the best!';

console.log(str1.endsWith('best', 17)); //true
posted @ 2020-06-13 11:07  H&K  阅读(223)  评论(0)    收藏  举报