Help with JS and functions parameters

后端 未结 6 1736
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-31 19:26

Does JS support two functions with the same name and different parameters ?

function f1(a, b)
{
// a and b are numbers
}

function f1(a, b, c)
{
// a is a string         


        
6条回答
  •  醉话见心
    2021-01-31 19:40

    Javascript only uses the function that was defined last.

    http://weblogs.asp.net/jgalloway/archive/2005/10/02/426345.aspx

    You will need to implement your own logic inside the function to determine which parameters were passed in.

提交回复
热议问题