<p>JavaScript doesn't seem to have a native <code>trim()</code> method. How can I trim white spaces at the start and end of a string with JavaScript?</p>

according to
this page
the best all-around approach is
```
```
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
```
```
Of course if you are using jQuery , it will provide you with an optimized trim method.