title: Angular array is not retaining its value after copying it to another and clearing it off
body: <p>I am creating 2 arrays 1st has some value and 2nd is empty. After assigning items from 1st to 2nd array I am clearing 1st array, but it also clears the 2nd array as well.</p>
  
  <p>My Code:</p>
  
  <pre><code>  array1: any = [1, 2, 3, 4, 5];
    array2: any = [];
  
    ngOnInit() {
      this.array2 = this.array1;
      this.array1.length = 0;
  
      console.log('I cleared Array1');
      console.log(this.array1);
  
      console.log('Array2 Clears Automatically');
      console.log(this.array2);
    }
  </code></pre>
  
  <p>Here is Stackblitz sample:
  <a href="https://stackblitz.com/edit/angular-yfhdi3?file=src%2Fapp%2Fapp.component.ts" rel="nofollow noreferrer">https://stackblitz.com/edit/angular-yfhdi3?file=src%2Fapp%2Fapp.component.ts</a></p>
  
  <p>I don't want array2 to loose its value, as after assigning the value I want to do a loop on array2.</p>