Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to push array into another non empty array in typescript? join if needed

this array contains atleast 10 objects

 array: any[] = [];

When a function is called, an array is expected to contain both existing and new objects from "item".

 function () {
    var timeline = this.service.fetchservice(10)
    .map((result : Response) => result.json())
    .subscribe(item=> {
          this.array.push(item);
        });
    }

error in console

ERROR TypeError: _this.array.push is not a function
like image 487
Kofi Sammie Avatar asked Oct 12 '25 14:10

Kofi Sammie


1 Answers

something like:

 this.results = this.results.concat(data.results);
like image 110
Carsten Avatar answered Oct 15 '25 19:10

Carsten