这是一个对象数组,
var data = [
{"label" : "1", "value" : 12},
{"label" : "1", "value" : 12},
{"label" : "1", "value" : 12},
{"label" : "1", "value" : 12}
];
我该如何动态添加这些值?我尝试了以下代码但没有成功:
var lab =["1","2","3", "4"];
var val = [42,55,51,22];
var data = new Array();
for(var i=0; i<4; i++){
data[i].label = lab[i];
data[i].value = val[i];
}