String.prototype.trim() Method in String Class of Javascript Syntax with Examples
2377 Views
Usage
trim() used to remove whitespaces from the sting.
if more than one whitespace given between the strings this function allows only one whitespace and remove other whitespaces.
Syntax
String.trim();
Example
var userName = "ab c d e ";
//Removes the whitespaces if it more than one.keeps only one whitespace between elements
var char1 = userName.trim();
document.write("The element is "+char1+" .");