xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

ES6 version repeatify

ES6 version repeatify


String.prototype.repeatify = String.prototype.repeatify || function (times = 1) {
  return [...``.padStart(times, ` `)].map((item, i) => item = this).join(``);
};

`abx`.repeatify(3);
// "abxabxabx"

refs

https://stackoverflow.com/a/62155265/5934465



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2021-01-05 14:20  xgqfrms  阅读(80)  评论(2编辑  收藏  举报