0
这是包含会计和销售数组的对象数组employees
。是否可以在一次推送中将新条目添加到会计和销售数组中?将对象添加到for循环中的'Json Array of Objects'
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.
sales: [ // Sales is another array in employees.
{
"firstName": "Sally", // First Element
"lastName" : "Green",
"age" : 27
},
{
"firstName": "Jim", // Second Element
"lastName" : "Galley",
"age" : 41
}
] // End "sales" Array.
} // End Employees
'employees.accounting.push(...)'?问题是什么?你能向我们展示你正在尝试使用的'for'循环吗? – JLRishe 2014-09-18 19:31:05
我只是担心从三个不同的数组中挑选来创建单个对象。没有什么是错误的推动。 for(i = 0; i
Jude
2014-09-18 19:35:35
好吧,我不知道我们应该猜测,当你从来没有告诉过我们'arrayfirstname','arraylastname'和'arrayage'。请努力在您提出的问题中包含所有相关信息。 – JLRishe 2014-09-18 19:38:22