I have an HTML file which imports two files:
graph.js and main.js
The main file contains logic which accesses a phone’s accelerometer/records acceleration and it is a purely javascript file. The Graph.js file contains a single JQuery function $(…..)
Is it possible to access a variable in main.js from graph.js?
Yes jQuery is written in JavaScript and it can access any variable declared in that page via import of other JavaScript files. As you are trying to access variable in
onloadof document, I don’t see any problem, because other scripts should already have been loaded before that.