Today to write a div+css analog JS information box class Library encountered a problem, I hope that when I did not pass the parameters of the past, automatically use the "prompt information" as the window title. I tried to write this.
Copy Code code as follows:
function MessageBox (title= "") {
}
There is no doubt that I failed to run (otherwise I would not send this blog)
Finally after a Baidu, found such a good thing
Copy Code code as follows:
function Test (a) {
var b=arguments[0]?arguments[0]:50;
Return a + ': ' +b;
}
According to my humble understanding, arguments is probably something like an array, with the subscript starting from 0, which represents the parameter of the function.
For example, the arguments[0 in the example above represents the parameter a
In fact, arguments[0]?arguments[0]:50 can also be written: Arguments[0] | | 50; The wording is quite concise. Above, is the method of setting the function parameter default value in JS