I have the following error. When I use splice in 1 array, it deletes the element in both arrays. Code:
export class AgendarpacientesComponent implements OnInit {
arrayPrueba: number[]=[1,2,3,4,5]
}
constructor(){
this.metodo();
}
ngOnInit() {}
metodo(){
let arrayAux = this.arrayPrueba;
arrayAux.splice(1,1);
console.log(this.arrayPrueba);
}
the result of console log is: [1,3,4,5] and I've used the splice method only on arrayAux. I don't know why this is happening.
Thanks for helping !