javascript remove space from string

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

// Example
removeSpaces('hel lo wor ld');      // 'helloworld'var str = "  Some text ";
str.trim();
// str = "Some text"var str = "  Some text ";
str.trim();str = str.trim();
Source

Also in JavaScript: