The problem of assignment Association of ts Array

recently I was learning ng2, but found a problem with array assignment. I just wanted to assign the value of list1 to list2, but they made an association.

Code:

export class AppComponent {

  public list1 = [];
  public list2 = [];

  constructor() {
    this.list1 = ["1","2"];

    this.list2 = this.list1;

    this.list1.push("3");

    console.log(this.list2);
  }

}

output:

(3)["1", "2", "3"]
Mar.06,2021

this.list2 = this.list1;
this sentence is equivalent to
your house number is "list1", and now there is another house number called "list2", which eventually points to your house. I suggest you make up the knowledge of stack.


simple way:

this.list2.push(...list1);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30fd7-40d9d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30fd7-40d9d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?