how to remove spaces in javascript

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

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'var str = "  Some text ";
str.trim();value = value.trim();var str = '/var/www/site/Brand new document.docx';

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

Also in JavaScript: