我有一个JavaScript数组,copyCommands
,我想推入一些项目。但是,我似乎无法正确添加另一个项目数组到父对象autoGenData
。如何将一个对象数组放入另一个对象?
//autoGenData is the object, copyCommands is an array
autoGenData.copyCommands.push({
CopyFrom: UnitFrom,
//CopyTo: //array that needs to hold CopyOptions and Unit
});
//Need to add these into CopyTo
//CopyOptions: checkedItems,
//Unit: localUnitTo
什么是添加CopyOptions
和unit
到push
命令CopyTo
部分正确的语法?
是CopyOptions和单位还数组? –
它们是我想要创建的数组的元素 - “copyTo”。 – Thassa