Can't Access Variable from other Javascript File

Viewed 559

I am trying to access a variable from another file in JavaScript, and I'm not able to. When I try to print that variable out, for example, Intellisense suggests the variable. However, when I actually run it, I get the error Uncaught ReferenceError: myVariable is not defined The variable is definitely declared in my file ('homePage.js').

I thought that all variables in Javascript were global, so I'm not sure why this is happening. All my files are in the same folder. Do I need to import something or am I just doing something completely wrong?

Thank you!

2 Answers

You can also move variables into session state / cookie and pull it back into the other script from there.

Related