title: How to not change object origin in javascript while service is running
body: <p>So I have a declared constants variable object. i.e:</p>
  <pre><code>const objData = {
      project: {
          name: '',
          age: 0,
          subProject: {
              name: '',
              age: 0
          }
      }
  }
  </code></pre>
  <p>And the function that returns the objData:</p>
  <pre><code>const dataSchema = () =&gt; {
      return objData;
  }
  </code></pre>
  <p>The flow is, I want to insert data into my table/collection in my database. So that's why I'm using constants to declare schema, and then I just insert with the returned dataSchema.</p>
  <p>This is my func to set value into dataSchema:</p>
  <pre><code>const mappingData1 = (data) =&gt; {
      try {
          const dataScheme = Object.assign({}, dataSchema())
          dataScheme.project.name = data.name;
          dataScheme.project.age = data.age;
  
          return dataScheme;
      }catch(err){
          return err; //return wrapper error here
      }
  }
  
  const mappingData2 = (data) =&gt; {
      try {
          const dataScheme = Object.assign({}, dataSchema())
          dataScheme.project.subProject.name = data.name;
          dataScheme.project.subProject.age = data.age;
  
          return dataScheme;
      }catch(err){
          return err; //return wrapper error here
      }
  }
  </code></pre>
  <p>Call mappingData schema func, and insert data into db:</p>
  <pre><code>//this bellow statement will be called in insertProjectData func, and called in the first time
  const data = { name: 'Someone', age: 7 }
  const mappedData = await mappingData1(data)
  const result = await this.command.insertData(mappedData)
  ===================================================================================
  //this bellow statement will be called in insertSubProjectData func, and called after insertProjectData func
  const data = { name: 'Someone', age: 7 }
  const mappedData = await mappingData2(data)
  const result = await this.command.insertData(mappedData)
  </code></pre>
  <p>The problem is, when the service is running, and insertSubProjectData func is called after insertProjectData func, why project.name and project.age is setted too with the value from insertProjectData func? even though i didn't set project.name and project.age in insertSubProjectData? It's like the original data (objData) is has been modified. I already use Object.assign too, to create a new object</p>
  <p>Any idea please? thank you!</p>