C style pointers in jscript
Wat i want to do is to pass my value type variables in jscript by reference. I know objects lik arrays and programmer defined objects are passed by reference. But how do i pass value type by reference to a function so that the function can actually alter the original copy of the variable at the caller`s location?
[314 byte] By [
hitai] at [2007-11-19 21:00:50]

# 1 Re: C style pointers in jscript
I am a little confused. Is this what you mean?
<script language="JavaScript">
function doaddition(var1, var2){
var addsum = var1 + var2;
alert(addsum);
}
doaddition(5, 17);
</script>
# 2 Re: C style pointers in jscript
i think what he wanted is to pass a variable by reference to a function, and once the stored value of the parameter was chaged inside the function the outside variable also changed (hence they point to same memory address).. but javascript/jscript supports only passing by value.
<script language="javascript">
var var1 = 25;
change(var1);
alert(var1); // var1 is still has a value of 25
function change(param1) {
param1 = param1 / 5;
return;
}
</script>