From 2b979660e95725c798455edcde5d383844a3d44c Mon Sep 17 00:00:00 2001 From: shubhansu-kr Date: Mon, 2 May 2022 00:07:42 +0530 Subject: [PATCH] Part 3 --- ES6ModuleSystem/02_Part2.mjs | 10 +++++++++- ES6ModuleSystem/03_Part3.mjs | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ES6ModuleSystem/03_Part3.mjs diff --git a/ES6ModuleSystem/02_Part2.mjs b/ES6ModuleSystem/02_Part2.mjs index 693d464..62e775b 100644 --- a/ES6ModuleSystem/02_Part2.mjs +++ b/ES6ModuleSystem/02_Part2.mjs @@ -4,6 +4,14 @@ import * as util from './00_Import.mjs'; // Instead of importing each object explicitly, we can just export // all of the objects using astrix and store it in a obj -console.log(util);f + +// this function is also being executed in par3.mjs :? +console.log(util); console.log(util.adder(3, 54), util.maxi(3, 5)); +export const power4 = (num) => { + return num ** 4; +} + +// Export different module obj +export * as utility from './00_Import.mjs' ; \ No newline at end of file diff --git a/ES6ModuleSystem/03_Part3.mjs b/ES6ModuleSystem/03_Part3.mjs new file mode 100644 index 0000000..1d7c054 --- /dev/null +++ b/ES6ModuleSystem/03_Part3.mjs @@ -0,0 +1,15 @@ +// To import from two different files, There are various ways + +// 1. Multi level Importing - Import obj of base to derive and derive to +// derive2 and so on + +import {power4, utility} from './02_Part2.mjs' + +console.log(power4(4)); + +// Error : Util is not exported +// console.log(util.adder(3, 54), util.maxi(3, 5)); + +// now that utility is imported +console.log(utility.cubic(3)) ; +console.log(utility) ; \ No newline at end of file