CKTIS / JavaScript
String.prototype.trimStart() — remove leading whitespace
trimStart() returns text with leading whitespace and line terminators defined by ECMAScript removed. It leaves the original string unchanged and preserves characters inside the text and at its end.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
string.trimStart()String.prototype.trimStart() removes the longest initial sequence of characters belonging to ECMAScript's WhiteSpace or LineTerminator sets. These include spaces, tabs, newlines, and the non-breaking space U+00A0. This does not mean every invisible Unicode character: U+200B is not removed.
The call string.trimStart() takes no parameters and returns a string value. Strings are immutable, so the original remains unchanged; save or pass on the result to use it. Interior and trailing characters remain untouched. Empty text and text consisting entirely of removable characters produce "".
Unlike trimStart(), trimEnd() removes these characters only from the end, while trim() removes them from both ends. You cannot supply a custom set of characters to remove. The method is generic: when used through String.prototype.trimStart.call(value), it converts an acceptable receiver to text; receivers null and undefined cause a TypeError.
The method was introduced in ECMAScript 2019. trimLeft is a legacy compatibility alias; prefer trimStart in new code. The language specification is not a browser compatibility table: check availability in the target environment with typeof String.prototype.trimStart === "function". Having Node 24 in a repository does not establish browser support.
Examples
const text = "\t\n\u00A0Hello world ";
const result = text.trimStart();
console.log(JSON.stringify(result));
console.log(result.endsWith(" "));
console.log(text.startsWith("\t"));Result
"Hello world " true true
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.