Community
Participate
Working Groups
While JavaScript does not support overloading a function like Java it is possible to call a function with different numbers of arguments or types. The function can then perform introspection and decide what to do. Several JavaScript libraries use this to implement setters and getters. If a function is called without and argument it acts as a getter. If it's called with an argument it acts as a setter. JSDoc has a native way to support this http://code.google.com/p/jsdoc-toolkit/issues/detail?id=157 an other option imaginable would be to simply repeat the function several times. Steps to Reproduce: 1. create a JavaScript library with one of the attached files 2. type jQuery("a") and hit Ctrl+Space Expected Behavior You get two "text" functions in the completion proposal, one with an argument, one without. Actual Behavior You only get one "text" function in the completion proposal.
Created attachment 197356 [details] function overlading using JSDoc
Created attachment 197357 [details] function overloading repeating the function