Solved

JavaScript functions with the same name

Posted on 2015-02-19
1
54 Views
Last Modified: 2015-02-20
How do you call a JavaScript function that is defined  in more than one library?
Is there a namespace associated with the function?
0
Comment
Question by:metro156
1 Comment
 
LVL 22

Accepted Solution

by:
ambience earned 500 total points
ID: 40620766
You cant, there can only be one function with a name. However, you can do  something like


<script src="script1.js" />
<script>

    var module1 =  {
          func = SomeFuncWithName;
    };
</script>
<script src="script2.js" />
<script>

    var module2=  {
          func = SomeFuncWithName;
    };

    // call first func
    module1.func();

    // call second
    module2.func();
</script>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reference Error with plugin 1 31
Form with Modals 16 44
How to make interactive HTML code pages like w3school or Codecademy? 3 29
Sorting a string 1 15
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This article discusses how to create an extensible mechanism for linked drop downs.
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now