title: How to affect string object passed to a function
body: <p>This is a very very basic question but for some reason I'm struggling and cannot find a good reference to it.</p>
  
  <p>Say I have this <code>JScript</code> code running under <code>WSH</code>:</p>
  
  <pre><code>function func(myStr) {
      var res = "abc";
      myStr = res;
  }
  
  function main() {
      var myStr = new String();
  
      WScript.Echo(myStr);
      func(myStr);
      WScript.Echo(myStr);
  }
  
  main();
  </code></pre>
  
  <p>I passing <code>String</code> object to <code>func</code> and expect <code>func</code> to set the value of object. However, <code>func</code> uses <code>operator =</code> which does copy the content but generate a new reference </p>
  
  <p>I reviewed this post, <a href="https://stackoverflow.com/q/728360/1798187">How do I correctly clone a JavaScript object?</a>, and couldn't find what I was looking for.</p>
  
  <p>Do we have a simple, straightforward solution to this? </p>