【发布时间】:2019-11-15 12:52:21
【问题描述】:
案例1
let history = [{temp : 123}];
history.concat({temp:1234}); //[{temp :123}, {temp:1234}]
案例2
let history = [{temp : 123}];
history.concat([{temp:1234}]): //[{temp :123}, {temp:1234}]
案例3
let history = [{temp : 123}];
history.concat([[{temp:1234}]]); //[{temp :123}, [{temp:1234}]]
为什么 concat 方法在 case1 和 case2 中返回相同的输出?
根据我的情况,case1 和 case3 是预期的,但 case2 是意外的。
【问题讨论】:
标签: javascript arrays concat