我需要创建一个对象字面量数组,如下所示:
var myColumnDefs = [ {key:"label", sortable:true, resizeable:true}, {key:"notes", sortable:true,resizeable:true},......
在这样的循环中:
for (var i = 0; i < oFullResponse.results.length; i++) { console.log(oFullResponse.results[i].label); }
的值key应该results[i].label在数组的每个元素中。
key
results[i].label
var arr = []; var len = oFullResponse.results.length; for (var i = 0; i < len; i++) { arr.push({ key: oFullResponse.results[i].label, sortable: true, resizeable: true }); }