SlideShare a Scribd company logo
1 of 12
Node Modules
Ahmed Elbassel
Email: elbassel.n13@gmail.com
Skype: ahmed_elbassel
Node Modules
- What is Module? Why Module?
- Creating Module
- Importing Modules
- Pass parameters to module.
- Accessing parent module.
- Passing parameters to a running application
- Exercise
- Bonus exercise.
What is Module ?
- A module contains related code into a single file to be reused later.
- A module encapsulates related code into a single unit of code. When creating
a module, this can be interpreted as moving all related functions into a file.
- In Node.js, each file is a separate module.
Why Module ?
- Code organize, Code reuse, Clean code.
What is module? Why module?
Creating module
- Create ****.js file.
- Put your code in.
- Expose your functions and variables.
Importing a module
- To import greetings module, require it.
- A module is an object you can access it’s functions or fields.
Passing Parameter to A module
- Write the return of the module as function
- Pass as many parameters as needed.
- In importing module:
Accessing Parent module
- In your current module, use: module.parent.exports.****
- Example:
Accessing Parent module, Take care
- Node.JS is a single thread built on V8 JavaScript Engine.
- Take care of modules dependency and where you initialize your modules.
- An error occurs
Passing parameter to application
- Run app: node app.js param1 param2 param3 ….
- You can consume the parameters through array: process.argv
- process.argv[0]: is node itsellf.
- Process.argv[1]: the running file.
- Your parameters are stored in argv array: starting process.argv[2],
process.argv[3], ...
Exercise, very very simple Calculator
- This exercise just to get hands on coding.
- The requirements are:
- Write an application to do the following:
- Accept three parameters as: 3 + 9.
- Parse the input parameters.
- Write 2 modules: on module to do the calculations and the second is the app module.
- Print the output and exit the app.
Bonus Exercise
- This exercise is the same as previous, with some modifications.
- You can run the application without passing parameters
- Ask the user a question: Does he want to do some calculations?
- If no, exit the app.
- If yes, let him insert his data, for example: 3 + 9
- Print the output.
- Ask the user the same question again and repeat the above three points
- This link can help:
Questions

More Related Content

What's hot

Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarCypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarApplitools
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressionsHans Emmel
 
A walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 featuresA walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 featuresMichal Juhas
 
Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Yakov Fain
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java DevelopersYakov Fain
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2Knoldus Inc.
 
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use casessatejsahu
 
AngularJS 2.0 Jumpstart
AngularJS 2.0 JumpstartAngularJS 2.0 Jumpstart
AngularJS 2.0 JumpstartFilipe Falcão
 
Up & running with ECMAScript6
Up & running with ECMAScript6Up & running with ECMAScript6
Up & running with ECMAScript6Nir Kaufman
 
Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Hong Tat Yew
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codeMichal Juhas
 
What’s new in angular 2
What’s new in angular 2What’s new in angular 2
What’s new in angular 2Ran Wahle
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshopAssaf Gannon
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??Laurent Duveau
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Shivam Bharadwaj
 
The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5Johannes Weber
 

What's hot (20)

ASP.NET Core
ASP.NET CoreASP.NET Core
ASP.NET Core
 
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil TayarCypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
Cypress vs Selenium WebDriver: Better, Or Just Different? -- by Gil Tayar
 
Cypress first impressions
Cypress first impressionsCypress first impressions
Cypress first impressions
 
AngularJS Scopes
AngularJS ScopesAngularJS Scopes
AngularJS Scopes
 
Node.js
Node.jsNode.js
Node.js
 
A walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 featuresA walkthrough of JavaScript ES6 features
A walkthrough of JavaScript ES6 features
 
Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020Type script for_java_dev_jul_2020
Type script for_java_dev_jul_2020
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
 
Introduction to Angular 2
Introduction to Angular 2Introduction to Angular 2
Introduction to Angular 2
 
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use cases
 
AngularJS 2.0 Jumpstart
AngularJS 2.0 JumpstartAngularJS 2.0 Jumpstart
AngularJS 2.0 Jumpstart
 
Up & running with ECMAScript6
Up & running with ECMAScript6Up & running with ECMAScript6
Up & running with ECMAScript6
 
Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)Introduction to cypress in Angular (Chinese)
Introduction to cypress in Angular (Chinese)
 
PHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the codePHP Frameworks, or how I learnt to stop worrying and love the code
PHP Frameworks, or how I learnt to stop worrying and love the code
 
What’s new in angular 2
What’s new in angular 2What’s new in angular 2
What’s new in angular 2
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
 
Angular 2... so can I use it now??
Angular 2... so can I use it now??Angular 2... so can I use it now??
Angular 2... so can I use it now??
 
Nodejs
NodejsNodejs
Nodejs
 
Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?Why you should switch to Cypress for modern web testing?
Why you should switch to Cypress for modern web testing?
 
The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5The evolution of Angular 2 @ AngularJS Munich Meetup #5
The evolution of Angular 2 @ AngularJS Munich Meetup #5
 

Viewers also liked

03 json for java script
03 json for java script03 json for java script
03 json for java scriptAhmed Elbassel
 
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js: V8 JavaScript EngineRun-time of Node.js: V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript EngineGary Yeh
 
Programación CdA 5º de Educación Primaria
Programación CdA  5º de Educación PrimariaProgramación CdA  5º de Educación Primaria
Programación CdA 5º de Educación PrimariaÁngel Alsasua Santos
 
Faq häufig gestellte fragen
Faq häufig gestellte fragenFaq häufig gestellte fragen
Faq häufig gestellte fragenUlrich Kritzler
 
Canal de Panamá y Universidad
Canal de Panamá y UniversidadCanal de Panamá y Universidad
Canal de Panamá y Universidaddocenciagrupo02
 
Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Lionel Briand
 
Dynamic Website Personalization - Make your website more interactive.
Dynamic Website Personalization - Make your website more interactive.Dynamic Website Personalization - Make your website more interactive.
Dynamic Website Personalization - Make your website more interactive.LeadGen-IMPACT
 
Rest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerRest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerKumaraswamy M
 
Clasificacion de tornillos
Clasificacion de tornillosClasificacion de tornillos
Clasificacion de tornillosalexisadonay
 
Clase sociales 5°-03-06-17_plan lector 01_ficha 02
Clase sociales 5°-03-06-17_plan lector 01_ficha 02Clase sociales 5°-03-06-17_plan lector 01_ficha 02
Clase sociales 5°-03-06-17_plan lector 01_ficha 02IETI AJC Olga Lucía Lloreda
 
Industrial engineering – case study
Industrial engineering – case studyIndustrial engineering – case study
Industrial engineering – case studyJephin S John
 
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividades
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividadesClase castellano 5°-03-09-17_revisión_apuntes_y_actividades
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividadesIETI AJC Olga Lucía Lloreda
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSArmin Vieweg
 
jDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodjDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodNicolas Fränkel
 

Viewers also liked (20)

03 json for java script
03 json for java script03 json for java script
03 json for java script
 
Run-time of Node.js : V8 JavaScript Engine
Run-time of Node.js: V8 JavaScript EngineRun-time of Node.js: V8 JavaScript Engine
Run-time of Node.js : V8 JavaScript Engine
 
Programación CdA 5º de Educación Primaria
Programación CdA  5º de Educación PrimariaProgramación CdA  5º de Educación Primaria
Programación CdA 5º de Educación Primaria
 
Guía de aprendizaje 5 slideshare
Guía de aprendizaje 5 slideshareGuía de aprendizaje 5 slideshare
Guía de aprendizaje 5 slideshare
 
Faq häufig gestellte fragen
Faq häufig gestellte fragenFaq häufig gestellte fragen
Faq häufig gestellte fragen
 
Canal de Panamá y Universidad
Canal de Panamá y UniversidadCanal de Panamá y Universidad
Canal de Panamá y Universidad
 
Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...Improving Fault Localization for Simulink Models using Search-Based Testing a...
Improving Fault Localization for Simulink Models using Search-Based Testing a...
 
06 start node coding
06 start node coding06 start node coding
06 start node coding
 
Contexto Artistico e Cultural
Contexto Artistico e CulturalContexto Artistico e Cultural
Contexto Artistico e Cultural
 
Dynamic Website Personalization - Make your website more interactive.
Dynamic Website Personalization - Make your website more interactive.Dynamic Website Personalization - Make your website more interactive.
Dynamic Website Personalization - Make your website more interactive.
 
Rest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swaggerRest with java (jax rs) and jersey and swagger
Rest with java (jax rs) and jersey and swagger
 
Clasificacion de tornillos
Clasificacion de tornillosClasificacion de tornillos
Clasificacion de tornillos
 
Resins
ResinsResins
Resins
 
Clase sociales 5°-03-06-17_plan lector 01_ficha 02
Clase sociales 5°-03-06-17_plan lector 01_ficha 02Clase sociales 5°-03-06-17_plan lector 01_ficha 02
Clase sociales 5°-03-06-17_plan lector 01_ficha 02
 
Clase inglés 5°_03-09-17_check my notes
Clase inglés 5°_03-09-17_check my notesClase inglés 5°_03-09-17_check my notes
Clase inglés 5°_03-09-17_check my notes
 
Industrial engineering – case study
Industrial engineering – case studyIndustrial engineering – case study
Industrial engineering – case study
 
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividades
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividadesClase castellano 5°-03-09-17_revisión_apuntes_y_actividades
Clase castellano 5°-03-09-17_revisión_apuntes_y_actividades
 
Gettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJSGettings started with the superheroic JavaScript library AngularJS
Gettings started with the superheroic JavaScript library AngularJS
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
jDays - Spring Boot under the Hood
jDays - Spring Boot under the HoodjDays - Spring Boot under the Hood
jDays - Spring Boot under the Hood
 

Similar to 04_Node modules

Meteor presentation
Meteor presentationMeteor presentation
Meteor presentationscandiweb
 
Sample Project using design patterns and agile
Sample Project using design patterns and agileSample Project using design patterns and agile
Sample Project using design patterns and agileVicente Bolea
 
Angular Notes.pdf
Angular Notes.pdfAngular Notes.pdf
Angular Notes.pdfsagarpal60
 
Angular.ppt
Angular.pptAngular.ppt
Angular.pptMytrux1
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slidesDavid Barreto
 
Workforce_Management_System
Workforce_Management_SystemWorkforce_Management_System
Workforce_Management_SystemAshok Mishra
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript Rohit Bishnoi
 
Tasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfTasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfacsmadurai
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
0-Slot08-09-10-Module-Functions.pdf
0-Slot08-09-10-Module-Functions.pdf0-Slot08-09-10-Module-Functions.pdf
0-Slot08-09-10-Module-Functions.pdfssusere19c741
 
Angular Presentation
Angular PresentationAngular Presentation
Angular PresentationAdam Moore
 
Node Session - 2
Node Session - 2Node Session - 2
Node Session - 2Bhavin Shah
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentationdharisk
 

Similar to 04_Node modules (20)

Meteor presentation
Meteor presentationMeteor presentation
Meteor presentation
 
Sample Project using design patterns and agile
Sample Project using design patterns and agileSample Project using design patterns and agile
Sample Project using design patterns and agile
 
Angular Notes.pdf
Angular Notes.pdfAngular Notes.pdf
Angular Notes.pdf
 
Meteor
MeteorMeteor
Meteor
 
09 express, moooore
09 express, moooore09 express, moooore
09 express, moooore
 
Angular.ppt
Angular.pptAngular.ppt
Angular.ppt
 
Angular performance slides
Angular performance slidesAngular performance slides
Angular performance slides
 
Workforce_Management_System
Workforce_Management_SystemWorkforce_Management_System
Workforce_Management_System
 
Angular2 with TypeScript
Angular2 with TypeScript Angular2 with TypeScript
Angular2 with TypeScript
 
NodeJs Modules1.pdf
NodeJs Modules1.pdfNodeJs Modules1.pdf
NodeJs Modules1.pdf
 
Tasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdfTasks In this assignment you are required to design and imp.pdf
Tasks In this assignment you are required to design and imp.pdf
 
Angular2 and You
Angular2 and YouAngular2 and You
Angular2 and You
 
008.module
008.module008.module
008.module
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
Visual programming
Visual programmingVisual programming
Visual programming
 
0-Slot08-09-10-Module-Functions.pdf
0-Slot08-09-10-Module-Functions.pdf0-Slot08-09-10-Module-Functions.pdf
0-Slot08-09-10-Module-Functions.pdf
 
Angular Presentation
Angular PresentationAngular Presentation
Angular Presentation
 
Node Session - 2
Node Session - 2Node Session - 2
Node Session - 2
 
Angularjs2 presentation
Angularjs2 presentationAngularjs2 presentation
Angularjs2 presentation
 
angular
angularangular
angular
 

More from Ahmed Elbassel

More from Ahmed Elbassel (8)

13 mongoose
13 mongoose13 mongoose
13 mongoose
 
12 mongo db_and_nodejs
12 mongo db_and_nodejs12 mongo db_and_nodejs
12 mongo db_and_nodejs
 
11 schema design & crud
11 schema design & crud11 schema design & crud
11 schema design & crud
 
10 mongo db
10 mongo db10 mongo db
10 mongo db
 
08 express introduction
08 express introduction08 express introduction
08 express introduction
 
07 restful webservices design
07 restful webservices design07 restful webservices design
07 restful webservices design
 
Airbnb Java Script style guide
Airbnb Java Script style guideAirbnb Java Script style guide
Airbnb Java Script style guide
 
Story of java
Story of javaStory of java
Story of java
 

Recently uploaded

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxhumanexperienceaaa
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 

Recently uploaded (20)

OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptxthe ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
the ladakh protest in leh ladakh 2024 sonam wangchuk.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 

04_Node modules

  • 1. Node Modules Ahmed Elbassel Email: elbassel.n13@gmail.com Skype: ahmed_elbassel
  • 2. Node Modules - What is Module? Why Module? - Creating Module - Importing Modules - Pass parameters to module. - Accessing parent module. - Passing parameters to a running application - Exercise - Bonus exercise.
  • 3. What is Module ? - A module contains related code into a single file to be reused later. - A module encapsulates related code into a single unit of code. When creating a module, this can be interpreted as moving all related functions into a file. - In Node.js, each file is a separate module. Why Module ? - Code organize, Code reuse, Clean code. What is module? Why module?
  • 4. Creating module - Create ****.js file. - Put your code in. - Expose your functions and variables.
  • 5. Importing a module - To import greetings module, require it. - A module is an object you can access it’s functions or fields.
  • 6. Passing Parameter to A module - Write the return of the module as function - Pass as many parameters as needed. - In importing module:
  • 7. Accessing Parent module - In your current module, use: module.parent.exports.**** - Example:
  • 8. Accessing Parent module, Take care - Node.JS is a single thread built on V8 JavaScript Engine. - Take care of modules dependency and where you initialize your modules. - An error occurs
  • 9. Passing parameter to application - Run app: node app.js param1 param2 param3 …. - You can consume the parameters through array: process.argv - process.argv[0]: is node itsellf. - Process.argv[1]: the running file. - Your parameters are stored in argv array: starting process.argv[2], process.argv[3], ...
  • 10. Exercise, very very simple Calculator - This exercise just to get hands on coding. - The requirements are: - Write an application to do the following: - Accept three parameters as: 3 + 9. - Parse the input parameters. - Write 2 modules: on module to do the calculations and the second is the app module. - Print the output and exit the app.
  • 11. Bonus Exercise - This exercise is the same as previous, with some modifications. - You can run the application without passing parameters - Ask the user a question: Does he want to do some calculations? - If no, exit the app. - If yes, let him insert his data, for example: 3 + 9 - Print the output. - Ask the user the same question again and repeat the above three points - This link can help: