title: Sampling a random subset from an array
body: <p>What is a clean way of taking a random sample, without replacement from an array in javascript? So suppose there is an array</p>
  
  <pre><code>x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
  </code></pre>
  
  <p>and I want to randomly sample 5 unique values; i.e. generate a random subset of length 5. To generate one random sample one could do something like:</p>
  
  <pre><code>x[Math.floor(Math.random()*x.length)];
  </code></pre>
  
  <p>But if this is done multiple times, there is a risk of a grabbing the same entry multiple times.</p>