JavaScript 문자열 rtrim() 구현

1 개요[ | ]

자바스크립트 rtrim() 구현
JavaScript 문자열 rtrim() 구현
JavaScript
Copy
var str = "  HELLO  ".replace(/\s+$/,'');
console.log("("+str+")"); // (  HELLO)
(  HELLO) 
JavaScript
Copy
String.prototype.rtrim = function(){return this.replace(/^\s+/,'');}
var str = "  HELLO  ";
console.log("("+str.rtrim()+")"); // (  HELLO)
(HELLO  ) 

2 같이 보기[ | ]