I have two external JavaScript lib files I have to load on same JSP page. They both have a function called “autoSave()”, both without parameters. I cannot modify their signature as they are not my script files.
How can I call a function in script A or script B explicitly? How is the precedence decided?
The function defined by the second script will overwrite the function defined by the first one.
You can save a copy of the function from script A before including script B.
For example:
Note, by the way, that if script A calls
autoSaveby name, the script will call the wrongautoSaveand (probably) stop working.You could solve that by swapping in the
autoSavefunctions before calling functions from either script using wrapper methods.