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

String.prototype.trim() - 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.trim()

Baseline Widely available

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

String trim() .

trimStart() trimEnd() .

In this article

const greeting = "   Hello world!   ";

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

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

js
trim()

.

str . .

str , . str .

trim()

str .

js
const str = "   foo  ";
console.log(str.trim()); // 'foo'

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


Web Proxy Viewer  |  New URL  |  Original Page