Javascript calls wrong function
This question already has an answer here:
What you are trying to do is called function overloading
. Unfortunately, it's not available in JavaScript.
But you can always try to kind of simulate it if you need.
Please check this link where there's a discussion about the best way to do it:
Function overloading in Javascript - Best practices
JavaScript中没有函数重载。
你可以使用arguments
。
function call(){
console.log("call param - " + arguments.length);
}
call(1);
call(1,2);
call(1,2,3);
链接地址: http://www.djcxy.com/p/51972.html
上一篇: 使相同的功能有不同的输入
下一篇: Javascript调用错误的函数