The previous article wrote about JS variables. js variables are also written here. Example:
<SCRIPT type = "text/JavaScript"> var STR = 'abcde'; var OBJ = new string (STR); function newtostring () {return 'Hello world! ';} Function func (VAL) {Val. tostring = newtostring;} // Example 1: input value func (STR); alert (STR); // Example 2: Input reference func (OBJ); alert (OBJ ); </SCRIPT>
TIPS: func (XXX); is the modification value.
In this case, you can look at the similar example above:
VaR A = 3.14; // declare and initialize a variablevar B = A; // copy the variable's value to a new variablea = 4; // modify the value of the original variablealert (B) // displays 3.14; the copy has not changedvar A = [1, 2, 3]; // initialize a variable to refer to an arrayvar B = A; // copy that reference into a new variablea [0] = 99; // modify the array using the original referencealert (B); // display the changed array [99,2, 3] using the new reference
Variable Declaration
There are two methods for variable Declaration: explicit and implicit.
Explicit usually refers to the use of VaR declaration, implicit (I .e., Declaration)
// Declare the variable var str = 'abc'; // declare the function Foo () {STR = 'abc';} // nanming exception object extry {//...} catch (Ex ){//...}