Arvind Chourasiya
Arvind Chourasiya

Reputation: 17432

How to push array elements in the same order of existing elements

I have array productData with 69 elements and productDatagreen with 659 elements in angular application. When I do push all the 659 elements are going inside index 69 same thing happening cancat. Then I have total length of array 70.

I need length of array 69+659 and items should be in same row. How can I do that. This is my code.

this.productData.push(this.productDatagreen)
this.productData= this.productData.concat([this.productDatagreen])    
this.mapImageSeries.data=this.productData;
this.Chart.validateData();

Array screenshot

enter image description here

Upvotes: 1

Views: 159

Answers (2)

Beingnin
Beingnin

Reputation: 2422

You could do something like this

this.productData =[...this.productData,...this.productDatagreen]
console.log(this.productData.length);//will console 728

Upvotes: 1

Arvind Chourasiya
Arvind Chourasiya

Reputation: 17432

As per the @phil's comment.

this.productData.push(...this.productDatagreen)

Worked for me.

Upvotes: 1

Related Questions