How to remove spaces from a string using JavaScript? How to remove spaces from a string using JavaScript? javascript javascript

How to remove spaces from a string using JavaScript?


This?

str = str.replace(/\s/g, '');

Example

var str = '/var/www/site/Brand new document.docx';document.write( str.replace(/\s/g, '') );