javascript trim spaces

JavaScript
const removeSpaces = str => str.replace(/\s/g, '');

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removedvalue = value.trim();var str = "       Hello World!        ";
alert(str.trim());yourvariable.trim()var str = '/var/www/site/Brand new document.docx';

document.write( str.replace(/\s/g, '') );
Source

Also in JavaScript: