美文网首页
字符串的扩展方法 includes()、startsWidth(

字符串的扩展方法 includes()、startsWidth(

作者: SY | 来源:发表于2022-07-13 11:09 被阅读0次

includes()是判断字符串中是否包含某一个字符,返回的是true 和 false 。

const msg = 'Hi, my name is lily'
console.log(msg.includes(name)) // true

startsWidth()是判断字符串当中起始位置是否包含某一个字符,返回的是true 和 false

const msg = 'Hi, my name is lily'
console.log(msg.startsWidth(Hi)) // true

endsWidth()是判断字符串当中起始位置是否包含某一个字符,返回的是true 和 false

const msg = 'Hi, my name is lily'
console.log(msg.endsWidth(lily)) // true

相关文章

网友评论

      本文标题:字符串的扩展方法 includes()、startsWidth(

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