javascript trim
snippet in javascript

js trim()

user6010

var str = '   foo  ';
console.log(str.trim()); // retorna 'foo'

// Outro exemplo de .trim() removendo whitespace de
// apenas um lado.

var str= 'foo    ';
console.log(str.trim()); // retorna 'foo'

javascript trim

user9172

var str=" I have outer spaces ";
var cleanStr=str.trim();//trim() returns string with outer spaces removed

js remove space before string

user3832

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

javascript split and trim

user4174

var arr = str.split(",").map(item => item.trim());

trim whitespace javascript

user3021


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

javascript trim spaces

user6454

value = value.trim();