JS : prototype trim()

javascript에는 trim()이 없다. 아래 프로토타입을 적용시켜봅시다.

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

String.prototype.ltrim = function() {
	return value.replace(/^s+/,"");
}
String.prototype.rtrim = function() {
	return value.replace(/s+$/,"");
}

Leave a Reply

Your email address will not be published.