Which method checks if a string contains a specified substring?

JavaScript Professional Easy

JavaScript Professional — Easy

Which method checks if a string contains a specified substring?

Key points

  • String.prototype.has() and String.prototype.contains() are not valid methods in JavaScript for checking substrings.
  • String.prototype.search() is used to search for a specified value in a string, not specifically for checking substrings.
  • String.prototype.includes() is the correct method for checking if a string contains a specified substring.

Ready to go further?

Related questions