String.prototype.repeatify=String.prototype.repeatify || function(times){
var str='';
for(var i=0;i<times;i++){
console.log('this',this)
// this指向调用这个函数的对象
str+=this;
}
return str
}

 

'hello'.repeatify(3)======>'hellohellohello'

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-09-11
  • 2022-12-23
  • 2021-08-05
  • 2022-02-20
猜你喜欢
  • 2021-07-26
  • 2021-06-27
  • 2021-11-02
  • 2021-05-29
  • 2021-06-07
  • 2021-08-31
相关资源
相似解决方案