+ 1
How to access javascript file from another javascript file linked with same html file ?
if I have a html file i.e index.html and two javascript files first is script1.js and second one is script2.js. how can I access functions from script1.js from script2.js. if I have a function in script1.js is function add(a,b){return a+b} , I want to access this function from script2.js just like a library how can I do that.
1 Réponse
+ 5
By exporting functions from first script and importing it from second.
More on modules
https://www.sololearn.com/learn/JavaScript/2981/