Knowledge Walls
Laya
Hyderabad, Andhra Pradesh, India
String.prototype.trim() Method in String Class of Javascript Syntax with Examples
2352 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+" .");
Output 
The element is ab c d e.
Best Lessons of "Javascript Syntax with Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details