Last Updated : 03 Nov, 2023
Lodash _.trimEnd() method is used to remove trailing white spaces or specified characters from the end of the given string.
Syntax:_.trimEnd( string, chars );Parameters:
This method returns the trimmed string.
Example 1: In this example, we are trimming the given array from the end.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
// The string to trim
let str = " Geeks-for-Geeks ";
// Using _.trimEnd() method
console.log(_.trimEnd(str));
Output:
" Geeks-for-Geeks"
Example 2: In this example, we are trimming the given array from the end from where the given value is present.
JavaScript
// Defining Lodash variable
const _ = require('lodash');
// The string to trim
let str = "----GeeksforGeeks----";
// Using _.trimEnd() method
// with specific characters to trim
console.log(_.trimEnd(str, "-"))
Output:
"----GeeksforGeeks"
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4