I tried the following, trying to pass a variable from one JavaScript file to another JavaScript variable. My first JavaScript file:
var x = "sachin";
My other JavaScript file can't access that x variable value. How do I solve this? I can access that x variable and same value in another file.
window.x = "sachin".var x = "sachin"is first js file .Then add next js file in below of the file .order is important .<script src="var x=sachin"></script> <script src="2nd file"></script>xin file 1 can't be accessed from file 2 but can be from file 3? In which order do you include the files?