ES6 - String.prototype.includes()



This function determines whether one string may be found within another string.

Syntax

The following syntax is for String.prototype.includes(), where, searchString is a string to be searched for within this string position is an optional parameter. It represents the position in this string at which to begin searching for searchString. The default value is 0.

str.includes(searchString[, position])

Example

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

The output of the above code will be as mentioned below −

true
false
Advertisements