The includes()
method
returns true
if the given substring is found in a string
otherwise
it returns false
.
We can achieve this using indexOf()
as well.
Although we can use indexOf()
instead of includes()
,
indexOf()
is used when we not only have to check
if a substring is found in a string,
but also know the index of the string from which
that substring is found.
includes()
is used when we only need
to check the presence of a substring.