This isn't all that new, but there's some clarity and refinements to be made to other references on the subject. Essentially, there's many cases where you might want to have a single JavaScript function which behaves differently based on what is passed to it.
These include 1-n scaling of arguments, default values for arguments, or even custom callbacks (a variation on function overloading). This can be extended even further by passing in objects.
JavaScript Function Arguments: Default Values, Passing Objects, and Overloading
No comments:
Post a Comment