Trimming Whitespace
JS · Stringsstr.trim()
str.trimStart()
str.trimEnd()const input = " hello@example.com ";
console.log(input.trim()); // "hello@example.com"
console.log(input.trimStart()); // "hello@example.com "
console.log(input.trimEnd()); // " hello@example.com"Note Essential for cleaning user input. Only removes whitespace characters (spaces, tabs, newlines), not other invisible characters.