title: javascript syntax question about splice in this statement -> copy.push(array.splice(i,1)[0])
body: <p>So this is a syntax question, I have been reading the MDN docs but i can't find a similar example. I got this particular code snippet from here: <a href="https://bost.ocks.org/mike/shuffle/" rel="nofollow noreferrer">https://bost.ocks.org/mike/shuffle/</a> as I was reading on randomizing arrays.</p>
  
  <p>Here is the full function:</p>
  
  <pre><code>    function shuffle(array) {
          var copy = [], n = array.length, i;
  
          // While there remain elements to shuffle…
          while (n) {
  
              // Pick a remaining element…
              i = Math.floor(Math.random() * n--);
  
              // And move it to the new array.
              copy.push(array.splice(i, 1)[0]);
          }
  
          return copy;
      }
  </code></pre>
  
  <p>Now, I have used it and modified it to fit my needs and it worked fine (although the splicing was a nightmare because it kept destroying my original data) but the point here is this line:</p>
  
  <pre><code>copy.push(array.splice(i, 1)[0]);
  </code></pre>
  
  <p>I hate not understanding something that would seem basic, but what is the [0] doing in this case? If i take it out the whole thing breaks, but im not sure if it;s part of the splice, or the push, or if its an index of the new array or the spliced array. IF anyone can help shed some light on this i would be very grateful!</p>