Passing data by value means that the data itself is stored in the variable. Assigning one variable to another copies the value.
Changing the value in one variable leaves the other unaffected.
Non-object values (primitives) are generally passed in this manner.
Passing data by value to a function means that the function cannot affect the value outside the function since it only has a copy of the value to work on.
In JavaScript, you cannot manipulate these parameter passing mechanisms. It will choose to pass by value or by reference according to the data type of the value being put into the argument. This is often the result of evaluating an expression. JavaScript takes care of all the type conversions for you.
Prev | Home | Next |
By reference | Up | byte |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |