Javascrip字符串扩充方法

//产生重复字符指定个数
if (!String.repeat) {
    String.prototype.repeat = function (l) {
        return new Array(l + 1).join(this);
    }
}

//清除前后导空格
if (!String.trim) {
    String.prototype.trim = function () {
        return this.replace(/^\s+|\s+$/g, ' ');
    }
}
posted @ 2012-03-25 00:02  天际翔龙  阅读(165)  评论(0编辑  收藏  举报