我有数组1是设置数组,数组2是数据数组。 现在,Array 2 date和Withdrawals是Swap ..!在未来将是其他领域是可交换的。
但阵列1是固定值和排列阵列2与阵列1始终相同。有关键和价值。
数组1:
{ date: 'Date',
withdrawals: 'Withdrawals',
deposits: 'Deposits',
Payee: 'Payee',
Description: 'Description',
ReferenceNumber: 'Reference Number' }
Fileds Array
数组2:
[ { date: 'Withdrawals',
withdrawals: 'Date',
deposits: 'Deposits',
Payee: 'name',
Description: 'Description',
ReferenceNumber: 'Reference Number' },
{ date: '0',
withdrawals: '28/11/13',
deposits: '500000',
Payee: 'John Roberts',
Description: 'Cheque deposit',
ReferenceNumber: 'Ref-1900' },
{ date: '75',
withdrawals: '22/11/13',
deposits: '0',
Payee: 'Smith123',
Description: 'Electronics purchase',
ReferenceNumber: 'Ref-2134' },
{ date: '4000',
withdrawals: '22/1/14',
deposits: '0',
Payee: 'Joseph',
Description: 'Insurance payment',
ReferenceNumber: 'Ref-9872' } ]
重新排列数组2与我的数组1相同
结果:
[ { date: 'Date',
withdrawals: 'withdrawals',
deposits: 'Deposits',
Payee: 'name',
Description: 'Description',
ReferenceNumber: 'Reference Number' },
{ date: '28/11/13',
withdrawals: '0',
deposits: '500000',
Payee: 'John Roberts',
Description: 'Cheque deposit',
ReferenceNumber: 'Ref-1900' },
{ date: '22/11/13',
withdrawals: '75',
deposits: '0',
Payee: 'Smith123',
Description: 'Electronics purchase',
ReferenceNumber: 'Ref-2134' },
{ date: '22/1/14',
withdrawals: '4000',
deposits: '0',
Payee: 'Joseph',
Description: 'Insurance payment',
ReferenceNumber: 'Ref-9872' } ]
答案 0 :(得分:0)
只需将array1分配给array2的第一个元素:
array2[0] = array1