在JS中自定义trim (全局)


Function.prototype.method = function(name, func) {
 this.prototype[name] = func;
 return this;
 };

 String.method('trim', function() {
 return this.replace(/^\s+|\s+$/g, '');
 });

posted @ 2012-01-30 13:27  柠檬Cool  阅读(278)  评论(0编辑  收藏  举报