Home >Web Front-end >JS Tutorial >Introduction to arguments and overloading in Javascript_javascript skills
Due to a language design error, arguments can be treated as an array.
It takes advantage of the fact that Javascript is Javasc
The arguments variable here provides an array-like interface for actual parameters. Because of the variable parameters of arguments here, we can use this interesting thing to do some interesting things, such as overloading.
Javscript reload
There is a question about overloading on stackvoerflow, so I have the first answer
} else {
}
Another answer is
It’s just that this method really doesn’t look good. Is our function going to look like this in the end?
It really doesn’t look good at all. Even if we change the switch..case, it won’t look good either.
Javascript arguments is not an array
arguments is not always an array as we see, sometimes it may not be.
arguments.callee
Reference to the currently executing function.
arguments.caller
Reference to the function that invoked the currently executing function.
arguments.length
Reference to the number of arguments passed to the function.