I want to push just the objects of array2 into array1.
array1 = [{name:'first'}, {name:'second'}];
array2 = [{name:'third'}, {name:'fourth'}, {name:'five'}];
// Desired result
array1 = [{name:'first'}, {name:'second'}, {name:'third'}, {name:'fourth'}, {name:'five'}];
copyArray() {
this.array1.push( this.array2 );
this.array2.splice();
}
When I run the copyArray function, the array2 itself was instead copied and not the objects. I got this:
Unwanted result
array1 = [{name:'first'}, {name:'second'}, [{name:'third'}, {name:'fourth'}, {name:'five'}]];
Can someone help me to fix this.