When values are passed to a function as it is called, primitive values are passed by value. This means that from inside the function you see a copy of the value and cannot damage the one outside.
Objects are passed by reference. If you modify the properties of an object that is passed into a function by way of an argument, you will be modifying the master instance of that object because there is only one.
This means that calling a function can have side effects that you may not expect unless you realize that this is happening.
| Prev | Home | Next |
| Function | Up | Function call |
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. | ||