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