What does the String.prototype.trim() method do?

JavaScript Associate Easy

JavaScript Associate — Easy

What does the String.prototype.trim() method do?

Key points

  • trim() specifically targets leading and trailing spaces
  • It does not affect spaces within the string
  • The method returns a new string without modifying the original
  • Useful for data validation and formatting

Ready to go further?

Related questions