Cannot read property 'push' of undefined when combining arrays

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

    I fixed in the below way with typescript

    1. Define and initialize firest

    pageNumbers: number[] = [];

    1. than populate it

      for (let i = 1; i < 201; i++) {
          this.pageNumbers.push(i);
      }
      

提交回复
热议问题