title: JavaScript array has length, but I can't get values
body: <p>I am trying to make my <a href="https://github.com/jasondavies/d3-cloud/" rel="nofollow noreferrer">d3 wordcloud</a> responsive. I have initialized the cloud like this:</p>
  
  <pre><code>var cloud = d3.layout.cloud()
      .rotate(0)
      .font("Open Sans, sans-serif")
      .fontWeight(600)
      .fontSize(d =&gt; {
          var size = d.size;
          return size;
      })
      .on("end", (words: any[]) =&gt; {
          this.text = this.vis.selectAll("text").data(words); // this.vis is the "g" node appended to the svg
          var b = this.text.enter().append("text");
          b.style("font-size", function (d) { return d.size + "px"; })
              .style("fill", (d: any) =&gt; "#272C2F")
              .attr("transform", function (d) {
                  return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")";
              })
              .text(function (d) { return d.text; });
      });
  </code></pre>
  
  <p>When the screen size changes I update it using this:</p>
  
  <pre><code>this.cloud.stop();
  this.cloud.size([this.$view.offsetWidth, this.$view.offsetHeight]); // this.$view.offsetWidth and this.$view.offsetWidth call the width and height of the view
  this.cloud.words(newlist); // newlist is an array with objects like this { text: string; count: number }
  </code></pre>
  
  <p>This works perfect the first time it is run. but then it does nothing. When I look in the code of d3 I see it has problems in this method:</p>
  
  <pre><code>d3_selection_enterPrototype.select = function(selector) {
      var subgroups = [], subgroup, subnode, upgroup, group, node;
      for (var j = -1, m = this.length; ++j &lt; m; ) {
          upgroup = (group = this[j]).update;
          subgroups.push(subgroup = []);
          subgroup.parentNode = group.parentNode;
          for (var i = -1, n = group.length; ++i &lt; n; ) {
              if (node = group[i]) {
                  subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i, j));
                  subnode.__data__ = node.__data__;
              } else {
                  subgroup.push(null);
              }
          }
      }
      return d3_selection(subgroups);
  };
  </code></pre>
  
  <p>If I call 'this' the first time, you can see it is an array and I can call those values inside the array. However when I run it again (after resizing my screen) the values are suddenly gone, even though the array still has the same length.</p>
  
  <p><a href="https://i.stack.imgur.com/1zPjQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1zPjQ.png" alt="result of console window when calling &#39;this&#39;"></a></p>
  
  <p>Is this a bug in d3? Or am I updating the cloud wrong?</p>