title: How to create a function to add a new array to an object in javascript
body: <p>I have data coming from the db and I want the user to be able to add a new array after adding the new changes. I want a function that can be used multiple times for different ajax calls. </p>
  
  <p>My object array is var basinSub and the content of the object array is:</p>
  
  <p>{BasinId: (array stuff), SubBasinId: (array stuff), SubBasinName: (array stuff)}</p>
  
  <p>How can I create a for key in data function that I can add a new array to the basinSub object?</p>
  
  <p>I was thinking something like this but it's not working:</p>
  
  <pre><code>function locationChangeData(value, desc) {
      for(var i in basinSub) {
          if(basinSub[i].value == value) {
              basinSub[i].desc = desc;
          }
      }
  }
  </code></pre>
  
  <p>Then I would call the function in the ajax success function:</p>
  
  <pre><code>locationChangeData(basinSub, newSubBasinToAddSub);
  </code></pre>
  
  <p>Which newSubBasinToAddSub is the new array to add to basinSub.</p>