What does `String.prototype.trim()` do?

JavaScript Associate Easy

JavaScript Associate — Easy

What does `String.prototype.trim()` do?

Key points

  • `trim()` eliminates leading and trailing spaces
  • It does not alter the content within the string
  • Useful for validating user input

Ready to go further?

Related questions