JavaScriptStringtrimEnd
trim

trimEndString

trimStart

Removes whitespace from the end of a string.

Syntax

str.trimEnd()

Example

Enter values below to update the example in real time.

const
console
trimEnd
const text = "  hello world  ";
console.log(text.trimEnd());   // "  hello world"