ES6 - String.prototype.includes() 函数
此函数确定是否可以在另一个字符串中找到一个字符串。
语法
以下语法适用于 String.prototype.includes(),其中,searchString 是要在此 string position 中搜索的字符串,是可选参数。它表示在此字符串中开始搜索 searchString 的位置。默认值为 0。
str.includes(searchString[, position])
示例
<script> let company='TutorialsPoint' console.log(company.includes('orial')) console.log(company.includes('orial',4)) </script>
上述代码的输出将如下所示 −
true false