How do I access a JavaScript array that is defined in another JavaScript file?
4 Answers
In order for this to work define your array as "var" (global variable). Go to the JS file where the array is and export it.
var globalArray;
export{globalArray, otherFunctionsYouExport};
Now go to the JS file you want the access to the array and import the global array. If you have multiple functions to import, use * and it will export everything between the brackets above.
import * as chooseName from './path of your JS file you export from';
// to use it write this
chooseName.globalArray // put here the rest of your code