title: Create a string of variable length, filled with a repeated character
body: <p>So, my question has been asked by someone else in it's Java form here: <a href="https://stackoverflow.com/questions/1802915/java-create-a-new-string-instance-with-specified-length-and-filled-with-specif">Java - Create a new String instance with specified length and filled with specific character. Best solution?</a></p>
  
  <p>. . . but I'm looking for its JavaScript equivalent.</p>
  
  <p>Basically, I'm wanting to dynamically fill text fields with "#" characters, based on the "maxlength" attribute of each field.  So, if an input has has <code>maxlength="3"</code>, then the field would be filled with "###".</p>
  
  <p>Ideally there would be something like the Java <code>StringUtils.repeat("#", 10);</code>, but, so far, the best option that I can think of is to loop through and append the "#" characters, one at a time, until the max length is reached.  I can't shake the feeling that there is a more efficient way to do it than that.</p>
  
  <p>Any ideas?</p>
  
  <p>FYI - I can't simply set a default value in the input, because the "#" characters need to clear on focus, and, if the user didn't enter a value, will need to be "refilled" on blur. It's the "refill" step that I'm concerned with</p>