Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8437921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:33:57+00:00 2026-06-10T07:33:57+00:00

I was included 2 javascript files in my app with script tag. I was

  • 0

I was included 2 javascript files in my app with script tag.

I was declared same variable in both script.

Now my question is, If I run the app will the variable same for two scripts or different for each script.

script 1(external file included).

var myvariable=10;
function(){
...
}

script 2 (external file)

var myvariable=20;
function(){
...
}

Is both myvariables are same for app?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:33:59+00:00Added an answer on June 10, 2026 at 7:33 am

    That depends on the scope.

    If both variables are global (ie: window.var) then the last variable will over-write the first variable with the same name.

    Look into closures to fix this (should you be using conflicting global variables).

    Good Luck !!

    TO YOUR UPDATED QUESTION:
    myvariable is in global scope, after script 2 executes myvariable will be 20.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to have Expression Language (EL) expressions included JavaScript files be
I want to minify java script files in my vs2010 web app ASP.NET solution.
Into my app I have included all needed JS files (my scripts, libraries such
I have some external Javascript files in my GWT app that I only want
Can anyone please recommend the best and easiest way to include multiple Javascript files
I'm having trouble trying to use a function in a javascript file I've included
I have a HTML that includes a Javascript file. This script contains a special
I have a site on domainA.com. It includes file.js from domainB.com: <script type=text/javascript src=http://www.domainB.com/file.js></script>
I have included Javascript with <%= javascript_include_tag application %> in my Rails 3.2 application.
Let's say I do this: $(#content).load(...); Within what I'm loading some javascript is included:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.