Concat in an empty array in Javascript

后端 未结 4 1181
再見小時候
再見小時候 2021-02-20 08:24

I was browsing through some code and I was wondering how this could be useful

grid.push([].concat(row));

In my understanding it is the same as<

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 08:38

    Check my variant:

    let arr = [];
    let tmp = [ 1, 2, '300$' ];
    arr.push(...tmp);
    

提交回复
热议问题