Cannot read property 'push' of undefined when combining arrays

前端 未结 8 2018
轮回少年
轮回少年 2021-02-01 12:18

When pushing an array\'s contents to another array I get

\"Uncaught TypeError: Cannot read property \'push\' of undefined\" error in this snippet.

8条回答
  •  借酒劲吻你
    2021-02-01 12:52

    You do not need to give an index.

    Instead of doing order[0].push(a[i]), just do order.push(a[i]).

提交回复
热议问题