javascript - JS fill Object as an array -


can tell me how fill element array

testdata = [     {         key: "one",         y: 200     },     {         key: "two",         y: 300     }        ]; 

example:

testdata=[]; testdata[]="one"; testdata[]="two"; 

it's better write function constructs json object. call createobject , can use loop like:

var list = []; for(var = 0; < 10; i++) {    var obj = createobject(i); //add other params if need    list.push(obj); } return list; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -