trim space frm string in javascript code example Example: js remove space before string Click to copyvar str = " Some text "; str.trim(); // str = "Some text"