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

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 发布文章使用:只允许注册用户才可以访问!


原文地址:https://www.cnblogs.com/xgqfrms/p/14235576.html