In one tutorial, the author said the "require" function can execute other files but it doesn't have access to other file's function and variable Unless they are exported by using module exports.
but if the file is JSON, it is exported default. Other files have access without module exports. Why?
For example,
index.js
let app = require('./app');
let greetings = require('./greetings.json');
console.log('greetings', greetings); // Won't throw error
app.greet(); // throw Error
app.js
function greet() {
console.log('hello')
}
greet()
greetings.json
{
english: "Hello",
spanish: "Hola"
}