ES6 之 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章