Skip to content
Advertisement

How to use the functions of the imported module in current module?

I have a module named test1.js which is being exported default as test1.

JavaScript

Then another file is there named mod1.js importing test1.js as follwing-

JavaScript

I tried to access the function of test1.js module using the ‘.’ which is not correct. I don’t know how to access this kind of functions, even is it possible or not?

Advertisement

Answer

Your syntax of exporting is wrong. You can use curly braces {} to export:

JavaScript

Similarly you can import the same way but you need to add on the file name:

JavaScript

For Reference: https://javascript.info/import-export

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement