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, ' ');
    }
}
原文地址:https://www.cnblogs.com/ywkpl/p/2416244.html