title: How to copy the values of an array (not pointing). Slice isn't working for me
body: <p>I have a function that tries to systematically add arrays to another multidimensional array. At each step of the way the arrays being added are calculated correctly, however, these calculations change the previously entered values. I've tried using slice but I'm clearly doing it wrong :(. </p>
  
  <p>Please see code below - it is the return <code>posMatrix</code> that is being affected.</p>
  
  <pre><code>function allPossibilities(hand) {
  
      var startingHandLength = hand.length;
      var potHand = Array.prototype.slice.call(hand);
      var scores = new Array();
      var posMatrix = new Array();
      var nextCard = 1;
      var progressStage = true;
      var finished = false; 
      var shallowArr = new Array();  
  
      do {
           scores = calculateScores(potHand);
      var maxScore = Math.max.apply(null, scores)
  
  
      shallowArr = potHand.slice();
  
      if (maxScore&gt;16.5)
          {posMatrix.push([shallowArr,maxScore])
           console.log(posMatrix);
           debugger;
  
              if (potHand.length !== startingHandLength)
                  {
                      do{
  
                          if(potHand[potHand.length-1][1] &lt; 10)
                               {
                                      potHand[potHand.length-1][1]++;
                                      progressStage = true;
  
                              }
                          else {potHand.pop();
  
                          potHand[potHand.length-1][1]++;}
  
                          } 
                          while(progressStage === false)
  
                  }
  
          }
      else
          {
  
          potHand.push(["Imaginary",1,"Imaginary"]);
  
          }
  
      progressStage=false;
  
      if(potHand.length === startingHandLength)
          {finished = true;}
  
  
      }
      while(finished === false);
  
  
          return posMatrix;
  
  
  }
  </code></pre>
  
  <p>If the starting hand > 16.5, the function works as none of the other code gets to run. But otherwise it does not. The final return should be an array where each element is looks like this: [[array],number]. The number seems to come out fine, but since it is not an object it is not affected. I would expect the [array]s to be different from one another, currently they are all the same.</p>