es6 repeat() 原字符串重复

 

repeat()返回一个新字符串,表示将原字符串重复n次。

var str = "x";
str.repeat(3) // "xxx"
 
var str1 = "hello";
str1.repeat(2) // "hellohello"

  

posted @ 2017-12-13 14:28  年少的你如此美丽  阅读(974)  评论(0编辑  收藏  举报