ES6 - String.prototype.includes()



此函式確定一個字串是否可以在另一個字串中找到。

語法

以下語法適用於String.prototype.includes(),其中,searchString 是要在該字串位置中搜索的字串,是一個可選引數。它表示在此字串中開始搜尋searchString的位置。預設值為 0。

str.includes(searchString[, position])

示例

<script>
   let company='TutorialsPoint'
   console.log(company.includes('orial'))
   console.log(company.includes('orial',4))
</script>

上述程式碼的輸出將如下所示:

true
false
廣告

© . All rights reserved.