var str = " Some text "; str.trim(); // str = "Some text"
var str=" I have outer spaces "; var cleanStr=str.trim();//trim() returns string with outer spaces removed
//Removing whitespace from String var str = " Hello World! "; console.log(str.trim());
var str = " Hello World! "; alert(str.trim());
value = value.trim();
yourvariable.trim()
var str = '/var/www/site/Brand new document.docx'; document.write( str.replace(/\s/g, '') );
<div style="white-space:pre-wrap"> <!-- New Line --> <!-- 2 space --> This is my text </div>