Alert (cc). I don't know why it cannot be displayed.
Reference content is as follows: <Script language = "javascript"> Function aa (bb ){ Bb ++; } Function zz (){ Var cc = 1; Aa (cc ); ; } Zz (); </Script> |
It is expected to be 1.
Reference content is as follows: <Script language = "javascript"> Function aa (bb ){ Bb. setDate (bb. getDate () + 1 ); }
Function zz (){ Var cc = new Date (); Aa (cc ); ; } Zz (); </Script> |
Why does cc Add a day?
Correct answer:
The key lies in your var cc = new Date (); this sentence seems to have indeed defined a local variable cc, but this is not the case; the fact is that the CC defined here is a date object instance. To illustrate this, you can use typeof (cc) to check the type, and you will find that the returned type is the object type. Therefore, the answer is clear. Now that the object type is used, the aa method called here is the same as passing an object instance in a frequently used advanced language.
Afterwards: You can also check the code output by alert 1, which should return the value type rather than the object type.