String.prototype.includes(str[, index])

String.prototype.includes(str[, index])

判断是否包含该字符串,可选参数是下标,代表搜索的起始位置

返回一个布尔值

let str = 'hello'
console.log(str.includes('h'));  //true
console.log(str.includes('h',0));  //true
console.log(str.includes('h',1));  //false
posted @ 2022-06-17 18:31  朱在春  阅读(15)  评论(0编辑  收藏  举报