title: How can I do the equivalent of "unzipping" arrays in Javascript?
body: <p><em><strong>I've been searching for a way to do the equivalent of zipping and unzipping arrays in Javascript. I've found a way to to the zipping, but not the unzipping.</strong></em></p>
  <p><strong>Overview:</strong></p>
  <p>I have two lists and the first members of the lists go together, the second members go together, etc. I would like to shuffle the lists to retain this pairing, and then end up with two separate lists once again.</p>
  <p><strong>In Python:</strong></p>
  <pre><code>#Define shuffle function
  shuffle = util.shuffle;
  
  #Lists of adult and child animals
  adult = [&quot;cat&quot;, &quot;dog&quot;, &quot;chicken&quot;]
  child = [&quot;kitty&quot;, &quot;puppy&quot;, &quot;chick&quot;]
  
  #zip them so I can shuffle while keeping pairs intact; then unzip them
  animals = list(zip(adult, child))
  random.shuffle(animals)
  adult, child = zip(*animals)
  adult = list(adult)
  child = list(child)
  </code></pre>
  <p><strong>In Javascript:</strong></p>
  <p>In the PsychoPy forums I found a way to do the zipping that will work in Pavlovia.</p>
  <pre><code>animals = []
  for Idx in range(len(adult)):
       animals.append([adult[Idx],labelsWhole[Idx%len(child)]])
  shuffle(animals)
  </code></pre>
  <p><strong>Outstanding:</strong></p>
  <p>But now how can I do the equivalent of: <code>adult, child = zip(*animals)</code>?</p>
  <p>I am aware of this <a href="https://stackoverflow.com/questions/4856717/javascript-equivalent-of-pythons-zip-function">similar post</a>. However, there is only one comment mentioning &quot;unzipping&quot; and it won't work in PsychoPy.</p>