JavaScript Hapus ruang dari string
const removeSpaces = str => str.replace(/\s/g, '');
// Example
removeSpaces('hel lo wor ld'); // 'helloworld'
Batman
const removeSpaces = str => str.replace(/\s/g, '');
// Example
removeSpaces('hel lo wor ld'); // 'helloworld'
str = str.trim();
var str = " Hello World! ";
alert(str.trim());
value = value.trim();
var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removed
var str = '/var/www/site/Brand new document.docx';
document.write( str.replace(/\s/g, '') );