-1
var data = [{"label":"Category A", "value":20}, 
            {"label":"Category B", "value":50}, 
            {"label":"Category C", "value":30}];

how to create these array dynamically and such type of array's are called as ?

1
  • 1
    can you explain your question more clearly? Commented Sep 25, 2015 at 11:36

3 Answers 3

2

just try this:

var data=[];
data.push({'label':category,'value':newVal});
Sign up to request clarification or add additional context in comments.

Comments

1

If you are making this array from some value, try this:

  var myData =[];
  myData.push({lable:yourlabel,value:yourValue});

you can loop through a data set and set yourlabel and your values in it

Comments

1
var data=[];

data.push({"label":"Category A", "value":20}); // push as many element you want by comma separated

These type of arrays are called as collection/ array of objects

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.