Correct me if am wrong the function require() imports the .js file somehow as copy past it in the current document so if the var name was both in two modules would the second override the first?
and how can i define file scope only variables
note that i want to define my variable outside any function in my .js file and not it be in the global scope
what are the solutions, does using the keyword var affects the variable scope, what define the scope other than function in javascript, can module object be useful for defining private variables in one file
module1.js
var name = 'i am module 1'
foo = () => console.log(name)
module.exports = foo
module2.js
var name = 'i am module 2'
foo = () => console.log(name)
module.exports = foo
main.js
const module1 = require('./module1')
const module2 = require('./module2')
module1() // "i am module 1" or "i am module 2"?
module2() // "i am module 2"
"i am module 1" or "i am module 2"?so, which is it? it will only output one of those, what has your extensive testing shown you?