Created
August 16, 2023 16:48
-
-
Save suhailgupta03/c68cdbd5e840b15ce6e29001ea88c77d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// FILE - 1 | |
function greet() { | |
console.log('Hello'); | |
} | |
module.exports = greet; | |
// this is the way to export a function | |
// from a module | |
// module means file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myGreetFunction = require('./test.js'); | |
// this basically means loading a file | |
// and assigning the exported variables | |
// to a variable in this file | |
// in this case, the exported variable is a | |
// function | |
console.log(myGreetFunction); |
EDIT: Change require('./test.js');
to require('./test1.js');
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
node test2.js