Introduction
In JavaScript, we may wish to check if a string contains a substring in ES6.
In this short tutorial, we'll learn how to check if a string contains another substring.
How to check if a string contains a substring in ES6
To check if a string contains a substring in ES6 we use string.includes(...)
method.
The string.includes(substring)
method returns true
if string
contains a substring
otherwise false
.
Conclusion
To find out if a string contains another substring in ES6 we use string.includes(...)
method.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}