聘我网

新概念招聘3.0

Javascript如何将字符串重复N遍?

vote up0vote downstar

Perl里这样就行了:

[usr@ ~]# perl -we "print 'test' x 5"
testtesttesttesttest
 

1 个答复

vote up0vote downcheck
String.prototype.repeat = function( num ){
    return new Array( num + 1 ).join( this );
}

'abc'.repeat(10)
链接

您的回答





不是您要找的问题? 浏览其他含有标签 的问题或者 自己问个.