Name

String.trim() — strip leading and trailing whitespace

Availability

ECMAScript 5

Synopsis

string.trim()

Returns

A copy of string, with all leading and trailing whitespace removed.

Get JavaScript: The Definitive Guide, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.