SOURCE

console 命令行工具 X clear

                    
>
console
var str = 'hello';
var s1 = str.repeat(2);
console.log(s1); // hellohello

String.prototype.repeatStr = function(n){
    if(isNaN(n) && n <= 0) return;
    var tempStr = '';
    for(var i=0;i<n;i++){
        tempStr += this;
    }
    return tempStr;
}

var s2 = str.repeatStr(3);
console.log(s2); //  hellohellohello
js重复字符串