English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
trim()The method removes the spaces at the beginning and end of the string.
string.trim()
var greeting = " Hello world! "; greeting.trim();Test and See‹/›
The numbers in the table specify the first browser version that fully supports the trim() method:
Method | |||||
trim() | Yes | 3.5 | 10.5 | 5 | 9 |
Return Value: | A new string representing the call string with spaces removed from both ends |
---|---|
JavaScript Version: | ECMAScript 1 |