title: Is this is a good way to generate a secure random string in JavaScript?
body: <p>Below is some code I wrote to generate a random string in JavaScript. Are there any security issues if I use the values received from this method as salts or tokens for users?</p>
  
  <pre><code>String.random = function(length, characters) {
      length = length === undefined ? 32 : length;
      characters = characters === undefined ? 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' : characters;
  
      var maxIndex = characters.length - 1;
      var string = '';
  
      for(var i = 0; i &lt; length; i++) {
          string += characters[Number.random(0, maxIndex)];
      }
  
      return string;
  }
  </code></pre>