includes() method in Javascript 🔥

Published: 19 March 2024
on channel: RoadsideCoder
3,376
236

The includes() method is a built-in function in JavaScript that allows you to check if a string contains another specified string. It returns true if the string contains the specified substring, and false otherwise.

Here's the syntax of the includes() method:
string.includes(searchString, position)

searchString: The substring that you want to check for in the main string.
position (optional): The index at which to begin searching for the substring within the main string. If not specified, the default is 0.