trim (JavaScript)

Removes white space from both ends of a string.

Defined in

String (Standard - JavaScript)

Syntax

trim() : string
Return value Description
string The string with white space removed.

Examples

The following example prints Paris Moscow Tokyo.
var cities = new String("   Paris   Moscow   Tokyo   ");
cities.trim()