title: Porting a ruby method to javascript
body: <p>I am trying to port some ruby code to javascript but am struggling with one particular line</p>
  
  <p>The Ruby code is below:
  It removes all the full rows from a game of tetris:</p>
  
  <pre><code>  # removes all filled rows and replaces them with empty ones, dropping all rows
    # above them down each time a row is removed and increasing the score.  
    def remove_filled
      (2..(@grid.size-1)).each{|num| row = @grid.slice(num);
        # see if this row is full (has no nil)
        if @grid[num].all?
          # remove from canvas blocks in full row
          (0..(num_columns-1)).each{|index|
            @grid[num][index].remove;
            @grid[num][index] = nil
          }
          # move down all rows above and move their blocks on the canvas
          ((@grid.size - num + 1)..(@grid.size)).each{|num2|
            @grid[@grid.size - num2].each{|rect| rect &amp;&amp; rect.move(0, block_size)};
  
            # I can't port this line
            @grid[@grid.size-num2+1] = Array.new(@grid[@grid.size - num2])
          }
          # insert new blank row at top
          @grid[0] = Array.new(num_columns);
          # adjust score for full flow
          @score += 10;
        end
      }
      self
    end
  </code></pre>
  
  <p>where @grid is a 2 dimensional array, initialised as follows:</p>
  
  <pre><code>@grid = Array.new(num_rows) {Array.new(num_columns)}
  </code></pre>
  
  <p>the javascript I have done so far is below</p>
  
  <p>I have noted in the comment which is the line I can't work out</p>
  
  <pre><code>removeFilled() {
              for (var i = 2; i &lt; this.grid.length; i++) {
                  var row = this.grid.slice(i);
  
                  var allFull = true;
  
                  for (var g = 0; g &lt; this.grid[i].length; g++ ) {
                      if (this.grid[i][g] == undefined) {
                          allFull = false;
                          break;
                      }
                  }
  
                  if (allFull) {
                      for (var j = 0; j &lt; this.numColumns; j++) {
                          this.grid[i][j].remove();
                          this.grid[i][j] = undefined;
                      }
  
                      for (var k = this.grid.length - i + 1; k &lt;= this.grid.length; k++) {
  
                          var rects = this.grid[this.grid.length - k];
  
                          for(var l = 0; l &lt; rects.length; l++) {
                              var rect  = rects[l];
                              if (rect) {
                                  rect.move(0, this.blockSize);
                              }
                          }
  
                          // ***this is the line I can't port
                          this.grid[this.grid.length - k + 1] = new Array(this.grid[this.grid.length - k]);
                      }
  
                      this.grid[0] =  new Array(this.numColumns);
                      this.score += 10;
                  }
              }
          }
  </code></pre>
  
  <p>any ideas how to port the line in question?</p>