0
I read in that reply here on the site I can import modules in javascript similar to what is done in python. However, I am not able to apply this in JS.
Follow an example. In python varies:
#arquivo mym.py
def my_sqr(a):
return a**(1/2)
In another file:
#arquivo main.py
from mym import my_sqr
my_sqr(9)
Output:
3
Already in the javascripit:
//arquivo mym.js
export my_sqr = function(a){
return a**(1/2)
}
Em main.js
import {my_sqr} from 'mym'
mym(9)
Error:
SyntaxError: Cannot use import statement outside a module