On this page
  1. String.trim
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

String.trim

Prev: replaceAll | Up: String | Next: matchAll
Rel: String, String, RegExp & Intl Guide
Ref: MDN Web Docs — String.trim
Tags: #public #web #javascript #builtins #string #tier/core


Signature & Overview

str.trim()  /* + trimStart(), trimEnd() */

Removes leading and trailing Unicode whitespace from str.

Notes & Pitfalls

Example

console.assert("  hello world\n".trim() === "hello world");

Linked from

Related notes