• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

which method will be called first

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.,
I have a small confusion in the execution of the methods in the java script. I have two functions with same name but different functionalities.one is in my JSP page and another one is in common.js file,which contains all java script functions.I am including this common.js in my jsp.I am calling my jsp function on page load.But the function which is in the common.js calling.I have included this file after my javasript function..as follows...
<script type="text/javascript">
function setThePageDetails(mode,formName){
}
</script>
<script language="JavaScript" type="text/javascript" src="common.js"> </script>
could you please tell me the order of execution of the functions....
Thanks in advance...
[ July 02, 2008: Message edited by: Bear Bibeault ]
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi suresh,

In javascript if you define two methods with same name, then method declared at the end gets executed no matter if you are passing one argument or two argument. In your case fist you declared a method in jsp and then you are importing js file that contains same method name.That's why it is calling function in js.

regards
darshan
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by suresh sai:


could you please tell me the order of execution of the functions....



A simple way to check/test this is to put an alert (different messages of course) and run the page!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have declare something more than once, the second one will overwrite the first when the parser gets to it.

Eric
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no function overloading in JavaScript. You must give each function a unique name.
 
suresh sai
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.,
Thank you for your solutions and suggestions.I have broken my confusion.
Once again thanks to darshan....
 
reply
    Bookmark Topic Watch Topic
  • New Topic