trim()Removes leading and trailing whitespace.Syntaxtext.trim()DescriptionCleans up spaces/newlines at the beginning and end of the text.ExampleLoading editor…▶ Try it yourselfExpected outputspaceWhen to use?Cleaning unwanted spaces in form inputs.Related commandsreplace() / replaceAll()← toUpperCase() / toLowerCase()slice() →