@Trim (JavaScript)

Removes leading and trailing spaces from a string.

Defined in

@Functions (JavaScript)

Syntax

@Trim(value:string) : string
Parameter Description
value A string or an array of strings.
Return value Description
string The trimmed string or the array of trimmed strings.

Usage

This function removes leading and trailing spaces, but not redundant spaces between characters.

If the parameter is an array, the result is an array with all elements trimmed.

Examples

This example trims the elements of an array and a string..
function p(stuff) {
	print("<<<" + stuff + ">>>");
}

var citiesArray = new Array("  Paris", "Berlin", "  London", "Moscow  ");
p(@Trim(citiesArray)); // <<<Paris>>>,<<<Berlin>>>,<<<London>>>,<<<Moscow>>>

var cities = "  Paris,   Berlin,    London,   Moscow   ";
p(@Trim(cities)); // <<<Paris,   Berlin,    London,   Moscow>>>