Check if a string contains a substring in JavaScript. #javascript



Check if a string contains a substring in JavaScript. #javascript

Check if a string contains a substring in JavaScript. #javascript

In this short video, I tried to quickly tell you all about the includes() method and indexOf() method in JavaScript, used to find the substring in a string.

String.includes() :-
It’s a simple method that returns a boolean value depending on whether the string contains the substring or not.

String.indexOf() :-
This method returns the index of the substring, you need to compare it to -1 to know if the substring was found or not.

Thanks for watching.
#javascript

Comments are closed.