Another Way of Javascript Method Overloading

In John Resig post, he presented a subtle method to support method overloading. It’s very useful when you have method overloading and each method behaves differently.

However, it adds overhead by wrap up existing methods inside a new function. For performance consideration, we check the length of arguments to execute different logics. It’s a more efficient and simple way to do the overloading. Examples:

This entry was posted in javascript, Web and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">