我有两个包含如下对象的数组:
json1[] = [{
"time": "00:00:00",
"speed": 15,
"speedlimit": 10
}, {
"time": "00:00:00",
"speed": 15,
"speedlimit": 10
}, {
"time": "00:00:00",
"speed": 15,
"speedlimit": 10
}];
json2[] = [{
"time": "00:00:00",
"Brake": 15
}, {
"time": "00:00:00",
"Brake": 15
}, {
"time": "00:00:00",
"Brake": 15
}];
使用上面两个对象我要创建第3个; json3[]
。我怎么能这样做?
答案 0 :(得分:0)
首先,请注意您的变量名称会导致语法错误,因为它们不能包含[]
个字符。
其次,要实现您的需求,您只需使用concat()
方法:
var json3 = json1.concat(json2);