This is so common that it is not even noted.
E.g., in JQuery, the on()
method has multiple call signatures:
.on( events [, selector ] [, data ], handler(eventObject) )
.on( events [, selector ] [, data ] )
A call to the first form looks like $('sel').on('click', function(e){/*handler*/})
. A call to the second form looks like $('sel').on({click: function(e){/*click handler*/}, mouseover: function(e){/*mouseover handler*/})
. Note that this demonstrates both "polymorphism" (i.e. arguments of different types) and "overloading" (i.e. optional arguments) in the Java/C# terminology.
Keyword arguments (simulated using a single object argument) are also common, e.g. $.ajax({settings})
.
So yes, this is done all over the place, but your referring to this as "overloading" is a category confusion. JS is neither staticly typed nor do its functions have a fixed number of function arguments. At call time you can supply as many or as few arguments as you want, regardless of what the function declares. You should view the argument list in the function declaration as a shorthand for array destructuring of the arguments
magic variable rather than as a fixed function signature.
The effect on speed is so minimal as to not even be a consideration.
As for when to do this vs when to use a separate function, that is entirely a program clarity and usability concern and probably subject to wide opinion.