Friday, January 16, 2026
HomeLanguagesJavascriptLodash _.trimStart() Method

Lodash _.trimStart() Method

The Lodash _.trimStart() method removes leading white spaces or specified characters from the given string.

Syntax:

_.trimStart( string, chars )

Parameters: This method accepts two parameters as mentioned above and described below:

  • string: This parameter holds the string to be trimmed.
  • chars: This parameter holds the charset to be specifically trimmed.

Return Value: This method returns a trimmed string.

Example 1:

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
var str = "   Geeks-for-Geeks   ";
 
// Using _.trimStart() method
console.log(_.trimStart(str));


Output:

"Geeks-for-Geeks   "

Example 2: explicitly trimming “-” from the string.

Javascript




// Defining Lodash variable
const _ = require('lodash');
 
var str = "----neveropen----";
 
// Using _.trimStart() method
console.log(_.trimStart(str, "-"))


Output:

"neveropen----"

Note: This will not work in normal JavaScript because it requires the lodash library to be installed and can be installed using npm install lodash.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32470 POSTS0 COMMENTS
Milvus
117 POSTS0 COMMENTS
Nango Kala
6838 POSTS0 COMMENTS
Nicole Veronica
11972 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12055 POSTS0 COMMENTS
Shaida Kate Naidoo
6975 POSTS0 COMMENTS
Ted Musemwa
7214 POSTS0 COMMENTS
Thapelo Manthata
6928 POSTS0 COMMENTS
Umr Jansen
6906 POSTS0 COMMENTS