javascript remove space from string
snippet in javascript

remove all spaces from a string javascript

user6409

.replace(/ /g,'')

javascript remove space from string

user1053

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

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'

js remove space before string

user2287

var str = "  Some text ";
str.trim();
// str = "Some text"

remove whitespace javascript

user515

var str = "  Some text ";
str.trim();

javascript string remove trailing spaces

user2972


 var str = "       Hello World!        ";
alert(str.trim());
 

js remove spaces

user2182

str = str.trim();