Cannot read property 'push' of undefined when combining arrays

前端 未结 8 2125
轮回少年
轮回少年 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:29

    answer to your question is simple order is not a object make it an array. var order = new Array(); order.push(/item to push/); when ever this error appears just check the left of which property the error is in this case it is push which is order[] so it is undefined.

提交回复
热议问题