Delete spaces in text in javascript

JavaScript
str.replace(/\s+/g, '')str = str.replace(/\s/g, '');var a = b = " /var/www/site/Brand new   document.docx ";

console.log( a.split(' ').join('') );
console.log( b.replace( /\s/g, '') ); 

Source

Also in JavaScript: