title: Angular4 copy object without reference?
body: <p>Inside a component I tried to copy an object from a service that could be modified inside the component, but should stay in the service.</p>
  
  <pre><code>private test;
  
  public ngOnInit(): {
    console.log(this.someService.test.someProperty) //'old'
    this.test = this.someService.test;
  
    //not working as well?!
    //this.test = Object.assign({}, this.someService.test);
    //this.test = Object.create(this.somerService.test);
  
    this.changeTest();
  }
  
  public changeTest(): void {
    this.test.someProperty = 'new';
  }
  </code></pre>
  
  <p>after the init both, <code>this.test.someProperty</code> as well as <code>this.someService.test.someProperty</code> are changed to <code>new</code> even though the last should stay <code>old</code>?</p>
  
  <p>Why is that happening, and how to only change properties of <code>this.test</code></p>