0

I have a JS file located in directory c:\myJSfiles\FileNumberOne.xyz

    //c:\myJSfiles\FileNumberone.xyz 

    var 1 = ThisValue1;
    var 2 - ThisValue2;
    and so on

In the same root directory, I have second JS file c:\myJSfiles\FileNumberTwo.xyz which I want to import the values of the variables from FileNumberOne.xyz

    //file: c:\myJSfiles\FileNumberTwo.xyz

    var A = "c:\myJSfiles\FileNumberOne.xyz", var 1;
    var B = "c:\myJSfiles\FileNumberOne.xyz", var 2;

How would I do this?

1
  • Would be great if you can share the exact extension of the file instead of saying "xyz" . Commented Oct 3, 2013 at 18:36

1 Answer 1

1

var 1 makes no sense, I assume you did it as an example only. Otherwise if you declare something in the first referenced script on the page, it will automatically be available in the second.

for example if you have in

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

line

var something = "hello"

you can reference the second script after the first

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

and in that script use that variable

alert(something); // will display hello
Sign up to request clarification or add additional context in comments.

5 Comments

Since I am a beginner, I am confused about applying your answer to my situation. var1 = ThisValue1 which is a number that changes frequently as is var 2. Would you be so kind as to write your answer so I can see how ThisValue1 makes it into the second JS file...Thanks
Please note, this JS is not a webpage.
@ddawson7 were do you run your JS then - what environment?
Within a charting application
Could you please elaborate? What is the application name, what technologies does it use? Windows, Web, etc.?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.