In JavaScript, you can access parameter names without explicitly naming them. For example:
function hi(){
if( arguments[0]=="andy"){
return;
}
alert(arguments[0]);
}
You can use arguments[0] Access the first parameter, and so on.
Use the arguments object to implement overloading, and use arguments.length to get the number of parameters of the function, as follows:
function hi(){
if(arguments.length==1){
alert(arguments[0]);
}
else if(arguments.length==2){
alert(arguments[0] arguments[1]);
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn