Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 79
  • Last Modified:

JavaScript functions with the same name

How do you call a JavaScript function that is defined  in more than one library?
Is there a namespace associated with the function?
0
Lawrence Avery
Asked:
Lawrence Avery
1 Solution
 
ambienceCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now