A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/String/trim below:

trim ยท WebPlatform Docs

trim Summary

Removes the leading and trailing white space and line terminator characters from a string.

Syntax
stringObj.trim()
stringObj
Required. A String object or string literal. This string is not modified by the trim method.
Return Value

The original string with leading and trailing white space and line terminator characters removed.

Examples

The following example illustrates the use of the trim method.

var message = "    abc def     \r\n  ";

 document.write("[" + message.trim() + "]");
 document.write("<br/>");
 document.write("length: " + message.trim().length);

 
 
 
Remarks

The characters that are removed include space, tab, form feed, carriage return, and line feed. See Special Characters (Windows Scripting - JScript) for a comprehensive list of white space and line terminator characters.

For an example that shows how to implement your own trim method, see Prototypes and Prototype Inheritance.

See also Other articles Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4