mozilla

Revision 164574 of Defining Functions

  • Revision slug: Talk:JavaScript/Guide/Obsolete_Pages/Defining_Functions
  • Revision title: Defining Functions
  • Revision id: 164574
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment New page: PauloAugusto: I think the prose about by-value parameters was correct before your rewrite. It's true that you can change the passed object's properties, but the "object reference" is itsel...

Revision Content

PauloAugusto: I think the prose about by-value parameters was correct before your rewrite. It's true that you can change the passed object's properties, but the "object reference" is itself passed by value:

> function x(o) { o = {a:2} }
> var obj = {a:1}
> x(obj)
> print(obj.a)
1

-- Nickolay 02:03, 15 September 2007 (PDT)

Revision Source

<p>PauloAugusto: I think the prose about by-value parameters was correct before your rewrite. It's true that you can change the passed object's properties, but the "object reference" is itself passed by value:
</p>
<pre class="eval">&gt; function x(o) { o = {a:2} }
&gt; var obj = {a:1}
&gt; x(obj)
&gt; print(obj.a)
1
</pre>
<p>-- <a href="User:Nickolay">Nickolay</a> 02:03, 15 September 2007 (PDT)
</p>
Revert to this revision