js要repeat一個(gè)字符串有幾種方法?除了es6自帶的repeat
西蘭花偉大炮
2017-05-01 23:48:58
TA貢獻(xiàn)313條經(jīng)驗(yàn) 獲得超208個(gè)贊
function?str_repeat(str,?num){? ????return?new?Array(?num?+?1?).join(?str?);? } str_repeat("hello",3);//hellohellohello
這是把字符串str重復(fù)num次的函數(shù)實(shí)現(xiàn)
舉報(bào)