如何动态创建 JavaScript 数组(JSON 格式)?
2022-08-30 04:14:19
我正在尝试创建以下内容:
var employees = {
"accounting": [ // accounting is an array in employees.
{
"firstName": "John", // First element
"lastName": "Doe",
"age": 23
},
{
"firstName": "Mary", // Second Element
"lastName": "Smith",
"age": 32
}
] // End "accounting" array.
} // End Employees
我从
var employees = new Array();
如何继续动态创建数组(可能会随变量而变化)?我似乎没有正确理解嵌套数组。firstName