Posted By

szsk on 08/02/06


Tagged

javascript String


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

vali29
jmonteiro


string_repeat


 / Published in: JavaScript
 

  1. String.prototype.repeat = function( num ) {
  2. for( var i = 0, buf = ""; i < num; i++ ) buf += this;
  3. return buf;
  4. }
  5.  
  6. //faster than
  7. //new Array( num + 1 ).join( this );

Report this snippet  

You need to login to post a comment.