title: References in aurelia
body: <p>I have a view which displays two different sets of data:
  Let's say proposalDetails and orderDetails.
  I have inherited some code that attempts to backup these two classes as members.</p>
  
  <p>The problem with the code in comments below is that the class functions are not cloned. Only the members. On the other hand keeping the 2 classes as references works just fine when I switch back and forth (between proposalDetails and orderDetails)</p>
  
  <p>Is there a reason that keeping reference is bad/incorrect practice?</p>
  
  <p><strong>Is there any danger that when I modify proposalDetails, orderDetails  is modified too?</strong> </p>
  
  <pre><code>switchView(viewName) {       
   if (viewName === 'proposal') {
  
        //this.orderBackup = JSON.parse(JSON.stringify(this.orderDetails));
        //this.orderDetails = JSON.parse(JSON.stringify(this.proposalDetails));
  
        //'Cloning' the member like this does not include all the class functions
        //I changed it to keep just the reference
  
        this.orderBackup = this.orderDetails;
        this.orderDetails = this.proposalDetails;
  
        $('#view_ordered').removeClass('active');
        $('#view_proposal').addClass('active');
  
        this.formDisabled = true;
        return;
      }
  
      this.orderDetails = this.orderBackup;
  }
  </code></pre>