trimEndメソッドは、文字列の末尾の空白を削除し、 元の文字列を変更せずに新しい文字列を返します。
trimEnd
文字列.trimEnd();
文字列' abcde 'の末尾の余分な空白を削除してみましょう:
' abcde '
let res = ' abcde '.trimEnd(); console.log(res);
コードを実行すると、文字列の末尾に空白がなくなっていることが確認できます:
' abcde'
trimStart
trim