JavaScript String.prototype.trimStart() Method
The trimStart() method removes white space from the start of a string only.
Description
The trimStart() method removes leading white space and leaves the end of the string alone. It is also available under its older name, trimLeft().
It removes the same characters as trim(): spaces, tabs, non-breaking spaces, line breaks and other Unicode white space. The original string isn't changed.
It's useful for cleaning up indented text, such as lines of a template literal or code being processed, where the end of each line should stay as it is. To remove only specific characters, such as leading zeros, use a regular expression like str.replace(/^0+/, '').
Syntax
string.trimStart()Return Value
A new string with white space removed from the start.
Example
Browser Support
The following information will show you the current browser support for the String.prototype.trimStart() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





