Lodash _.trimEnd() Method
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:
- string: It is the string that has to be trimmed. The default value is an empty string.
- chars: It is a set of characters that have to be trimmed from the string. It is an optional parameter. The default value is a whitespace.
Return Value:
This method returns the trimmed string.
Example 1: In this example, we are trimming the given array from the end.
Javascript
const _ = require( 'lodash' );
let str = " Geeks-for-Geeks " ;
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
const _ = require( 'lodash' );
let str = "----GeeksforGeeks----" ;
console.log(_.trimEnd(str, "-" ))
|
Output:
"----GeeksforGeeks"
Share your thoughts in the comments
Please Login to comment...