Initialization code is very similar to assignment statements in the main body of the code. There is a slight difference in that the assignment takes place before any code is executed.
If variables are not initialized they will contain the value undefined.
The initialization happens when the variable is declared using the var keyword.
Objects are initialized when they are constructed. This is a somewhat different process to that of initializing a variable.
If a variable is initialized to equal an object, it is really a reference to that object and not the object itself that gets stored in the variable.
See also: | Constant expression, Declaration, var |
Prev | Home | Next |
Inheritance | Up | Inline script |
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. |