Cannot form keyvalue pair in javascript in desired format
<p>I have formed a keyvalue pair in JavaScript using the below code:</p>

<pre><code>for(i=1;i&lt;=results.totpage;i++)
     {
       pushToAry(i,i);

     }
</code></pre>

<p>Assume results.totpage as 300.
The method <strong>pushToAry():</strong></p>

<pre><code>function pushToAry(name, val) {
//alert("In the array");
   var obj = {};
   obj[name] = val;
   ary.push(obj);  
}
</code></pre>

<p>where ary is defined as <strong>var ary = [];</strong>
Using the above format the result that comes out is like:</p>

<p><a href="https://i.stack.imgur.com/amIVy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/amIVy.png" alt="enter image description here"></a></p>

<p>But I want to make it like <code>[["key1", "value1"],["key2", "value2"],["key3", "value3"]]</code> i.e. to replace the 2nd brackets with the 3rd brackets.</p>

<p>Please help.</p>