title: How to add values to a JSON object?
body: <p>I have created an array with:</p>
  
  <pre><code>var msg = new Array();
  </code></pre>
  
  <p>then, I have a function that add values to this array, this function is:</p>
  
  <pre><code>function add(time, user, text){
      var message = [time, user, text];
      if (msg.length &gt;= 50)
          msg.shift();
  
      msg.push(message);        
  }
  </code></pre>
  
  <p>As you can see, if the array has 50 or more elements I remove the first with <code>.shift()</code>.
  Then I add an array as element.</p>
  
  <p>Ok, the code works perfectly, but now I have to loop the <code>msg</code> array to create a JSON obj.</p>
  
  <p>The JSON object should has this format:</p>
  
  <pre><code>var obj = [
  {'time' : time, 'user' : user, 'text' : text},
  {'time' : time, 'user' : user, 'text' : text},
  {'time' : time, 'user' : user, 'text' : text}
  ]
  </code></pre>
  
  <p>I mean...i have to loop msg array and then store all the values inside the JSON object.
  I do not know how to "concatenate" the element of the array inside json obj.</p>
  
  <p>Could you help me?</p>
  
  <p>Thank you very much in advance!</p>