If I have three files, basically something like this:
file_one.js:
const lol = () => {
console.log('Laughing out loud in file_one')
}
const funcOne = () => {
lol()
}
export default funcOne
file_two.js:
const lol = () => {
console.log('Laughing out loud in file_two')
}
const funcTwo = () => {
lol()
}
export default funcTwo
one_and_two_importer.js:
import funcOne from 'file_one'
import funcTwo from 'file_two'
funcOne()
funcTwo()
My assumption was that the lol function would be in the global scope and therefore would cause a namespace collision, but apparently this would not happen. Also, if I try to register the lol function in one_and_two_importer.js, I get an undefined error.
As reported, import inserts a module into the current region, but in which region are the constants used by the imported modules located?
source
share