Sometimes, we may want to check if a substring is in a JavaScript string in a case-insensitive manner.
In this article, we’ll check if a JavaScript string has a substring in a case-insensitive manner.
toLowerCase and String.prototype.indexOf
We can convert both the string and the substring we’re checking for the lower case to check if a substring is in a JavaScript string is in a case-insensitive manner.
For instance, we can write:
#javascript