Trim Javascript String : Remove space at starting or ending of string
You can do trim of any javascript string by below function.
function trim(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }
Example :
var triotips = " This is best site. "; alert(trim(triotips));
Result :
This is best site
If you are looking for trimming each value of Array in javascript then see here. Trim Array in Javascript: Trim elements of an array in Javascript