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