Home  • Programming • JavaScript

Creating Array of Objects in JavaScript

<script>
  var o={};
  o.name="jahid";
  o.age="30";
  
  var arr=[];
  
  arr.push(o);
  
  o={};
  o.name="Jone";
  o.age="50";
  
  arr.push(o);
  
  arr.push({'name':'Ridon','age':'34'});
  arr.push({'name':'Asha','age':'28'});
  
 alert(arr[0].name);
 alert(arr[1].name);
 alert(arr[2].name);
 alert(arr[3].name);
</script>

Comments 1


var json = '{"cool":"34.33","alsocool":"45454"}'; // is JSON
var o = JSON.parse(json); // is a javscript object
json = JSON.stringifyClock; // is JSON again
Copyright © 2024. Powered by Intellect Software Ltd