title: Returning Arrays and ChildNodes
body: <p>I have the following code:</p>
  
  <pre><code>var actionsAllowed = $(packet).find('actionsAllowed').get();
  
  var actionArray = $(actionsAllowed).each(function () {
      var actionNodes = this.childNodes;
      var actionNumber = actionNodes.length;
      var array = new Array(actionNumber)
  
      for (var i = 0; i &lt; actionNodes.length; i++) {
          var action = actionNodes[i].nodeName
          array[i] = action
          console.log(action);
      }
      return array;
  });
  </code></pre>
  
  <p>This searches the packet (XML) for <code>"actionsAllowed"</code> and returns it as <code>"[actionsAllowed]"</code>.</p>
  
  <p>I am then trying to create an array with each of the actions listed in the array.</p>
  
  <p>The <code>"this"</code> becomes <code>"actionsAllowed"</code> without the <code>"[ ]"</code> and that allows it to return the child nodes in the form "NodeList[ActionOne, ActionTwo, ActionThree]".
  I then get the length of the NodeList and create an array of that length.</p>
  
  <p>I then iterate over the NodeList and add each to the array.</p>
  
  <p>By the end, it returns the array as <code>"[ActionOne, ActionTwo, ActionThree]"</code>, which is great!</p>
  
  <p>BUT - this is the problem:</p>
  
  <p>The variable <code>"actionArray"</code> becomes <code>"Object[actionsAllowed]"</code>, instead of the array.</p>
  
  <p>Any idea why this is please? I have a theory but I'm unable to fix it =(</p>
  
  <p>Thank you!</p>