String.prototype.trim = function(){
	return this.replace(/(^\s*)|(\s*$)/gi, "");
};
String.prototype.ltrim = function(){
	return this.replace(/(^\s+)/, "");
};
String.prototype.rtrim = function(){
	return this.replace(/(\s+$)/, "");
};

사용법은..
var str = 'ABC   ' ;
str.trim();


 

+ Recent posts