Hi all,
Is there a way to make the following script work as i would expect it to?
I would expect an alert ('oldval'); but instead newval is alerted.
I think javascript uses (alot) of Cpointer-like (or C++reference-like) copying.
Is there a way to let javascript do some real copying???
Is there a way to make the following script work as i would expect it to?
Code:
<script language="javascript">
function constr () {
this.value = 'oldval';
this.someotherval = 'xxx';
}
var obj = new constr ();
obj.someotherval ='yyy';
var obj2 = obj;
obj2.value = 'newval';
alert(obj.value);
</script>
I would expect an alert ('oldval'); but instead newval is alerted.
I think javascript uses (alot) of Cpointer-like (or C++reference-like) copying.
Is there a way to let javascript do some real copying???