diff --git a/3. Module System/index.js b/3. Module System/index.js new file mode 100644 index 0000000..4b99615 --- /dev/null +++ b/3. Module System/index.js @@ -0,0 +1,13 @@ +// Core Module +const fs = require("fs"); +// Local Module +// const localModule = require("./localModule"); +const { printName, PI, student, Human } = require("./localModule"); +// Third Party Module / on node_modules +// const moment = require("moment"); + +// console.log(fs); +// console.log(localModule.printName("Drian"), localModule.PI); +console.log(student.printStudent(), new Human()); +// console.log(printName("Drian"), PI); +// console.log(moment); diff --git a/3. Module System/localModule.js b/3. Module System/localModule.js new file mode 100644 index 0000000..c3595d6 --- /dev/null +++ b/3. Module System/localModule.js @@ -0,0 +1,31 @@ +const printName = (name) => `Hi, ${name}`; + +const PI = 3.14; + +const student = { + name: "Drian", + age: 18, + // printStudent: function () {}, + // printStudent: () => {}, + printStudent() { + return `Hi, my name is ${this.name} and iam ${this.age} years old`; + }, +}; + +class Human { + constructor() { + console.log("Object human created"); + } +} + +// module.exports.printName = printName; +// module.exports.PI = PI; + +// module.exports = { +// printName: printName, +// PI: PI, +// student: student, +// Human: Human, +// }; + +module.exports = { printName, PI, student, Human };