From ee0309bd397ee085835db21db141f65dc3e178c3 Mon Sep 17 00:00:00 2001 From: Vivek Date: Sat, 18 Jun 2022 18:10:28 +0530 Subject: [PATCH] importing variables from other file --- addition.js | 7 ++++++- import var from other file.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 import var from other file.js diff --git a/addition.js b/addition.js index 68ef33b..204aa50 100644 --- a/addition.js +++ b/addition.js @@ -1,3 +1,8 @@ let a = 20; let b = 30; -console.log("Sum = " , a+b); \ No newline at end of file +console.log("Sum = " , a+b); + +module.exports = { + c : 50, + d : 'XYZ' +} \ No newline at end of file diff --git a/import var from other file.js b/import var from other file.js new file mode 100644 index 0000000..564f61e --- /dev/null +++ b/import var from other file.js @@ -0,0 +1,5 @@ +const impo= require('./addition'); +console.log(impo); +console.log(impo.c); +console.log(impo.d); +