首页 > Web开发 > 详细

添加一个js扩展方法

时间:2018-06-17 14:09:28      阅读:194      评论:0      收藏:0      [点我收藏+]


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‘

 

添加一个js扩展方法

原文:https://www.cnblogs.com/lwwen/p/9192698.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!