字符串方法

startsWith - 判断字符串是否以谁开头的

var str = 'ancdef'
 var res = str.startsWith('b')
 console.log(res);

endsWith - 判断 字符串是否以谁结尾的

var str = 'abcdef';
 var bool = str.endsWith('a')
 console.log(bool);

includes - 判断 字符串是否包含某个字符

var str = 'abcdef';
 var bool = str.includes('r')
 console.log(bool);

 

posted @ 2021-01-14 19:25  技术活当赏  阅读(42)  评论(0)    收藏  举报