[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String/trimStart [Back]  [Original]

String.prototype.trimStart() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

String.prototype.trimStart()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2020 1.

String trimStart() . trimLeft() .

In this article

const greeting = "   Hello world!   ";

console.log(greeting);
// Expected output: "   Hello world!   ";

console.log(greeting.trimStart());
// Expected output: "Hello world!   ";

js
trimStart()

trimLeft()

.

() str . .

str ( str ).

trim() , trimLeft . padStart() trimStart . trimLeft trimStart , . .

js
String.prototype.trimLeft.name === "trimStart";

trimStart()

str , .

js
let str = "   foo  ";

console.log(str.length); // 8

str = str.trimStart();
console.log(str.length); // 5
console.log(str); // 'foo  '

Specification
ECMAScript 2027 LanguageSpecification
# sec-string.prototype.trimstart


Web Proxy Viewer  |  New URL  |  Original Page