Javascript推送对象数组

时间:2017-11-09 06:11:24

标签: javascript

我有两个数组,我想合并到单个数组中。这是数组。

var array1 = '1510207073874:File {name: "1.Login.png", lastModified: 1504530252000, lastModifiedDate: Mon Sep 04 2017 18:34:12 GMT+0530 (IST), webkitRelativePath: "", size: 34338}';
var array2 = '151020704875:File {name: "1.Login.png", lastModified: 1504530252000, lastModifiedDate: Mon Sep 04 2017 18:34:12 GMT+0530 (IST), webkitRelativePath: "", size: 34338}';

我想将这两个数组合并为单个数组,如:

var array3 = '1510207073874:File {name: "1.Login.png", lastModified: 1504530252000, lastModifiedDate: Mon Sep 04 2017 18:34:12 GMT+0530 (IST), webkitRelativePath: "", size: 34338},
'151020704875:File {name: "1.Login.png", lastModified: 1504530252000, lastModifiedDate: Mon Sep 04 2017 18:34:12 GMT+0530 (IST), webkitRelativePath: "", size: 34338}';

1 个答案:

答案 0 :(得分:-1)

首先,你想要的不是合并,而是简单的连接。我认为可以使用“+”运算符将两个数组连接成一个数组。在javascript数组中是对象。

var array3=array1 + array2;

see image for more clearity