You are here: irt.org | FAQ | JavaScript | Object | Q1590 [ previous next ]
Variables are 'call by value', whereas objects are 'call be reference' as the following shows:
<script language="JavaScript"><!-- function byValue(a_variable) { a_variable *= a_variable; } function byReference(an_object) { an_object.a_property *= an_object.a_property; } var x = 12; byValue(x); document.write(x + '<br>'); // displays 12 var y = new Object(); y.a_property = 12; byReference(y); document.write(y.a_property + '<br>'); // displays 144 //--></script>