Create Json Array in Javascript Dynamically

This is an example to create Json Array in Javascript dynamically using new Array(), new Object() and .push().

<script>
   var obj = new Array();
   for(i = 1; i<=5; i++)
   {
   var jsonData = new Object();
        jsonData.key = "ID";
        jsonData.value  = i;
 obj.push(jsonData);  
   }

   console.log(obj);
</script>
 
 

Comments

Popular posts from this blog

Login with facebook using coldfusion

Create CSV file in Coldfusion Using CFFile

Get Previous One Day Data in Sql Server