SlideShare a Scribd company logo
Server-side JS Framework:
NodeJS
callback function
• A callback function is a function which is:
• accessible by another function, and
• is invoked after the first function if that first function completes
• This construct is very useful for asynchronous behaviour where we want an
activity to take place whenever a previous event completes.
• In JavaScript, pass a function as an argument to a function. This function
that is passed as an argument inside of another function is called a callback
function. For example,
<html>
<head>
<script>
function greet(name, callback)
{ document.write("<h1>" + 'Hi' + ' ' + name + "</h1>");
callback();
}
function callMe()
{ document.write("<h1>" + 'I am callback function' + "</h1>");
}
greet('Peter', callMe);
</script> </head> <body> </body> </html>
Benefit of Callback Function
• wait for the result of a previous function call and then execute another
function call.
• In this example, we are going to use the setTimeout() method to mimic the
program that takes time to execute, such as data coming from the server.
<script>
alert(1);
setTimeout(() => alert(2), 0);
alert(3);
</script>
Two types of programming models-
Synchronous and Asynchronous models
•Synchronous tasks happen in order — you must finish
task one before moving on to the next.
•Asynchronous tasks can be executed in any order, or
even simultaneously.
JavaScript
•JavaScript is dynamically typed single-threaded
interpreted languages for the Web.
•Dynamically typed language which means a variable can
hold any data type like String or Number in its lifetime and
JavaScript interpreter won’t complain about it.
•It’s single-threaded which means your JavaScript code runs
synchronously or sequentially line by line. It’s interpreted
which means you don’t need to compile your JavaScript
code.
JavaScript
•JavaScript Interpreter also called a JavaScript Engine.
•V8 is the JavaScript engine designed by Google and
used in the Google Chrome browser while
SpiderMonkey is a JavaScript engine developed by
Mozilla for their Firefox browser.
•Javascript is a single-threaded language, meaning
that just one line of code may be run at once.
•Javascript is single-threaded because, originally, it was
only a web browser scripting language created to
serve the needs of a single user on a single window
of the browser, eliminating the need for
multithreading.
What is server-side JavaScript?
•JavaScript is a single-threaded language, it knows
how to get things done one at a time.
•It can’t do asynchronous tasks or run JavaScript code
in multiple threads for efficiency.
•JavaScript is abbreviated as JS or .js/.JS (dot J S) to
state that an entity is related to JavaScript, like
Node.js or ReactJS or AngularJS.
What is server-side JavaScript?
•JavaScript is used on the web, it needs to be
secure. Hence, using JavaScript, you can’t access the
computer it is running on, like File System, IO,
Networking, etc.
What is server-side JavaScript?
• Web APIs sometimes do their job in separate thread
allowing other JavaScript code to run normally while the
job is running in the background.
• Once the job is done, it then informs the main JavaScript
thread.
• For example, setTimeout(callback, delay) function is not
part of ECMAScript specification, it is provided by the
browser to perform an asynchronous operation. The
callback function is executed in the main JavaScript thread
once delay milliseconds has elapsed.
how JavaScript runs in a browser
The concept of server-side JavaScript
•You can take any JavaScript engine, wrap inside an
application that gives a clean interface to take the user’s
JavaScript code and execute it in the JavaScript engine.
•You can also provide APIs to perform operations like File
System IO, Networking, etc. which do not run on
JavaScript engine.
how JavaScript runs on a server
Server-side JS Framework
•It provide tools and libraries that simplify
common web development tasks,
•including routing URLs to appropriate handlers,
interacting with databases, supporting sessions
and user authorization, formatting output (e.g.
HTML, JSON, XML), and improving security
against web attacks.
Introduction to Node.js
•Node.js is an open-source server side runtime environment
built on Chrome's V8 JavaScript engine.
•It provides an event driven, non-blocking
(asynchronous) I/O and cross-platform runtime
environment for building highly scalable server-
side applications using JavaScript.
Node.js
•Node.js is nothing but JavaScript running on the
server
•Node JS is asynchronous and event-driven
JavaScript runtime build for scalable network
applications.
•Although JavaScript in web browser is single thread
and synchronous,
•Node JS is asynchronous and can use multi threads
for I/O or others tasks in background.
Introduction to Node.js
• Node.js is an open-source and cross-platform runtime
environment for executing JavaScript code outside a
browser.
• NodeJS is not a framework and it’s not a programming
language.
Node.js = Runtime Environment + JavaScript Library
Needs of Node.js
• Enables JavaScript to run outside the browser
• Makes use of Google's V8 VM for interpreting JavaScript
• Additional modules which simplifies JavaScript development
• It’s a runtime and also a library!
• JavaScript is an event-driven language, and Node takes this as an advantage to
produce highly scalable servers, using an architecture called an event loop.
• For Creating High Performance Servers.
• Non-Blocking I/O.
• Event and Callback based.
• Only one Thread and one call stack
Node JS based applications
• Web Application Development.
• Hybrid Apps Development. (Both Desktop & Mobile)
• API Development.
• Chat Applications.
• Streaming Services for Video and Audio.
Node JS Based Web Servers
• Netflix
• Linkedin
• Uber
• Paypal
• Nasa
• Medium
• Slack
• Twitter
• Free Charge
• Flipkart Seller
Node JS Based Desktop Applications
• VS Code
• Brackets
• Atom
• MongoDB Compass
• Postman
• Discord
• Dropbox
• Figma
• Github Desktop
• Microsoft Teams
• Skype
• Wordpress Desktop
• Whatsapp for Desktop
• Facebook Messenger for Desktop
Node.js Installation Procedure
steps to setup development environment to develop a Node.js application.
tools/SDK are required for developing a
Node.js application on any platform
•Node.js
•Node Package Manager (NPM)
•IDE (Integrated Development Environment) or
TextEditor
Install Node.js on Windows
•official web site https://nodejs.org.
•It will automatically detect OS and display download
link as per your Operating System.
•For example, it will display following download link for
64 bit Windows OS.
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
concept of server-side JavaScript / JS Framework: NODEJS
Verify Installation
concept of server-side JavaScript / JS Framework: NODEJS
Install Node.js on Mac/Linux
concept of server-side JavaScript / JS Framework: NODEJS
After installation, verify the Node.js installation using terminal window and enter
the following command. It will display the version number of Node.js installed on
your Mac.
$ node -v
Node.js Console/REPL
Node.js comes with virtual environment called REPL (aka Node shell). REPL stands for Read-Eval-Print-Loop. It is a quick and
easy way to test simple Node.js/JavaScript code.
To launch the REPL (Node shell), open command prompt (in Windows) or terminal (in Mac or UNIX/Linux) and type node
as shown below. It will change the prompt to > in Windows and MAC.
concept of server-side JavaScript / JS Framework: NODEJS
If you need to write multi line JavaScript expression or function then just press Enter whenever you want to write
something in the next line as a continuation of your code. The REPL terminal will display three dots (...), it means
you can continue on next line. Write .break to get out of continuity mode.
To exit from the REPL terminal, press Ctrl + C
twice or write .exit and press Enter.
JavaScript file
• 1. create a sample.js file through text editior / notepad
• 2. with in sample.js file - type
console.log("Hello World");
3. Save your file again
4. Open cmd - Move to file location
5. Executing the node filename
node sample.js

More Related Content

Similar to concept of server-side JavaScript / JS Framework: NODEJS (20)

PDF
Node.js for beginner
Sarunyhot Suwannachoti
 
PDF
Node.js.pdf
gulfam ali
 
PDF
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
ODP
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
PPTX
Intro to Node.js (v1)
Chris Cowan
 
PPTX
NodeJS - Server Side JS
Ganesh Kondal
 
PDF
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
PPTX
NodeJS guide for beginners
Enoch Joshua
 
PDF
Node intro
Vishal Sharma
 
PDF
NodeJS for Beginner
Apaichon Punopas
 
PPTX
Proposal
Constantine Priemski
 
PPTX
node_js.pptx
dipen55
 
PPT
18_Node.js.ppt
KhalilSalhi7
 
PPT
18_Node.js.ppt
MaulikShah516542
 
PDF
Introduction to Node.js
Jack Franklin
 
PPTX
Nodejs intro
Ndjido Ardo BAR
 
PPTX
Nodejs
dssprakash
 
PPT
Introducción y comandos en NodeJS slodte
lmcsenatic
 
PPTX
An overview of node.js
valuebound
 
Node.js for beginner
Sarunyhot Suwannachoti
 
Node.js.pdf
gulfam ali
 
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
Introduce about Nodejs - duyetdev.com
Van-Duyet Le
 
Intro to Node.js (v1)
Chris Cowan
 
NodeJS - Server Side JS
Ganesh Kondal
 
540slidesofnodejsbackendhopeitworkforu.pdf
hamzadamani7
 
NodeJS guide for beginners
Enoch Joshua
 
Node intro
Vishal Sharma
 
NodeJS for Beginner
Apaichon Punopas
 
node_js.pptx
dipen55
 
18_Node.js.ppt
KhalilSalhi7
 
18_Node.js.ppt
MaulikShah516542
 
Introduction to Node.js
Jack Franklin
 
Nodejs intro
Ndjido Ardo BAR
 
Nodejs
dssprakash
 
Introducción y comandos en NodeJS slodte
lmcsenatic
 
An overview of node.js
valuebound
 

More from Kongu Engineering College, Perundurai, Erode (20)

PPTX
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
PPTX
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
PPT
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
PPTX
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
PPT
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
PPT
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PPTX
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
PPTX
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
Bootstarp installation.pptx
Kongu Engineering College, Perundurai, Erode
 
PPTX
nested_Object as Parameter & Recursion_Later_commamd.pptx
Kongu Engineering College, Perundurai, Erode
 
Introduction to Generative AI refers to a subset of artificial intelligence
Kongu Engineering College, Perundurai, Erode
 
Introduction to Microsoft Power BI is a business analytics service
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database (MongoDB) using Node JS & Connect Node.js with NoSQ...
Kongu Engineering College, Perundurai, Erode
 
Node.js web-based Example :Run a local server in order to start using node.js...
Kongu Engineering College, Perundurai, Erode
 
Concepts of Satellite Communication and types and its applications
Kongu Engineering College, Perundurai, Erode
 
Concepts of Mobile Communication Wireless LANs, Bluetooth , HiperLAN
Kongu Engineering College, Perundurai, Erode
 
Web Technology Introduction framework.pptx
Kongu Engineering College, Perundurai, Erode
 
Computer Network - Unicast Routing Distance vector Link state vector
Kongu Engineering College, Perundurai, Erode
 
Android SQLite database oriented application development
Kongu Engineering College, Perundurai, Erode
 
Android Application Development Programming
Kongu Engineering College, Perundurai, Erode
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
A REST API (also called a RESTful API or RESTful web API) is an application p...
Kongu Engineering College, Perundurai, Erode
 
SOA and Monolith Architecture - Micro Services.pptx
Kongu Engineering College, Perundurai, Erode
 
Connect to NoSQL Database using Node JS.pptx
Kongu Engineering College, Perundurai, Erode
 
nested_Object as Parameter & Recursion_Later_commamd.pptx
Kongu Engineering College, Perundurai, Erode
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PPT
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Interview paper part 3, It is based on Interview Prep
SoumyadeepGhosh39
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
The Builder’s Playbook - 2025 State of AI Report.pdf
jeroen339954
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Ad

concept of server-side JavaScript / JS Framework: NODEJS

  • 2. callback function • A callback function is a function which is: • accessible by another function, and • is invoked after the first function if that first function completes • This construct is very useful for asynchronous behaviour where we want an activity to take place whenever a previous event completes.
  • 3. • In JavaScript, pass a function as an argument to a function. This function that is passed as an argument inside of another function is called a callback function. For example, <html> <head> <script> function greet(name, callback) { document.write("<h1>" + 'Hi' + ' ' + name + "</h1>"); callback(); } function callMe() { document.write("<h1>" + 'I am callback function' + "</h1>"); } greet('Peter', callMe); </script> </head> <body> </body> </html>
  • 4. Benefit of Callback Function • wait for the result of a previous function call and then execute another function call. • In this example, we are going to use the setTimeout() method to mimic the program that takes time to execute, such as data coming from the server. <script> alert(1); setTimeout(() => alert(2), 0); alert(3); </script>
  • 5. Two types of programming models- Synchronous and Asynchronous models •Synchronous tasks happen in order — you must finish task one before moving on to the next. •Asynchronous tasks can be executed in any order, or even simultaneously.
  • 6. JavaScript •JavaScript is dynamically typed single-threaded interpreted languages for the Web. •Dynamically typed language which means a variable can hold any data type like String or Number in its lifetime and JavaScript interpreter won’t complain about it. •It’s single-threaded which means your JavaScript code runs synchronously or sequentially line by line. It’s interpreted which means you don’t need to compile your JavaScript code.
  • 7. JavaScript •JavaScript Interpreter also called a JavaScript Engine. •V8 is the JavaScript engine designed by Google and used in the Google Chrome browser while SpiderMonkey is a JavaScript engine developed by Mozilla for their Firefox browser.
  • 8. •Javascript is a single-threaded language, meaning that just one line of code may be run at once. •Javascript is single-threaded because, originally, it was only a web browser scripting language created to serve the needs of a single user on a single window of the browser, eliminating the need for multithreading.
  • 9. What is server-side JavaScript? •JavaScript is a single-threaded language, it knows how to get things done one at a time. •It can’t do asynchronous tasks or run JavaScript code in multiple threads for efficiency. •JavaScript is abbreviated as JS or .js/.JS (dot J S) to state that an entity is related to JavaScript, like Node.js or ReactJS or AngularJS.
  • 10. What is server-side JavaScript? •JavaScript is used on the web, it needs to be secure. Hence, using JavaScript, you can’t access the computer it is running on, like File System, IO, Networking, etc.
  • 11. What is server-side JavaScript? • Web APIs sometimes do their job in separate thread allowing other JavaScript code to run normally while the job is running in the background. • Once the job is done, it then informs the main JavaScript thread. • For example, setTimeout(callback, delay) function is not part of ECMAScript specification, it is provided by the browser to perform an asynchronous operation. The callback function is executed in the main JavaScript thread once delay milliseconds has elapsed.
  • 12. how JavaScript runs in a browser
  • 13. The concept of server-side JavaScript •You can take any JavaScript engine, wrap inside an application that gives a clean interface to take the user’s JavaScript code and execute it in the JavaScript engine. •You can also provide APIs to perform operations like File System IO, Networking, etc. which do not run on JavaScript engine.
  • 14. how JavaScript runs on a server
  • 15. Server-side JS Framework •It provide tools and libraries that simplify common web development tasks, •including routing URLs to appropriate handlers, interacting with databases, supporting sessions and user authorization, formatting output (e.g. HTML, JSON, XML), and improving security against web attacks.
  • 16. Introduction to Node.js •Node.js is an open-source server side runtime environment built on Chrome's V8 JavaScript engine. •It provides an event driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building highly scalable server- side applications using JavaScript.
  • 17. Node.js •Node.js is nothing but JavaScript running on the server •Node JS is asynchronous and event-driven JavaScript runtime build for scalable network applications. •Although JavaScript in web browser is single thread and synchronous, •Node JS is asynchronous and can use multi threads for I/O or others tasks in background.
  • 18. Introduction to Node.js • Node.js is an open-source and cross-platform runtime environment for executing JavaScript code outside a browser. • NodeJS is not a framework and it’s not a programming language. Node.js = Runtime Environment + JavaScript Library
  • 19. Needs of Node.js • Enables JavaScript to run outside the browser • Makes use of Google's V8 VM for interpreting JavaScript • Additional modules which simplifies JavaScript development • It’s a runtime and also a library! • JavaScript is an event-driven language, and Node takes this as an advantage to produce highly scalable servers, using an architecture called an event loop. • For Creating High Performance Servers. • Non-Blocking I/O. • Event and Callback based. • Only one Thread and one call stack
  • 20. Node JS based applications • Web Application Development. • Hybrid Apps Development. (Both Desktop & Mobile) • API Development. • Chat Applications. • Streaming Services for Video and Audio.
  • 21. Node JS Based Web Servers • Netflix • Linkedin • Uber • Paypal • Nasa • Medium • Slack • Twitter • Free Charge • Flipkart Seller
  • 22. Node JS Based Desktop Applications • VS Code • Brackets • Atom • MongoDB Compass • Postman • Discord • Dropbox • Figma • Github Desktop • Microsoft Teams • Skype • Wordpress Desktop • Whatsapp for Desktop • Facebook Messenger for Desktop
  • 23. Node.js Installation Procedure steps to setup development environment to develop a Node.js application.
  • 24. tools/SDK are required for developing a Node.js application on any platform •Node.js •Node Package Manager (NPM) •IDE (Integrated Development Environment) or TextEditor
  • 25. Install Node.js on Windows •official web site https://nodejs.org. •It will automatically detect OS and display download link as per your Operating System. •For example, it will display following download link for 64 bit Windows OS.
  • 34. Install Node.js on Mac/Linux
  • 36. After installation, verify the Node.js installation using terminal window and enter the following command. It will display the version number of Node.js installed on your Mac. $ node -v
  • 38. Node.js comes with virtual environment called REPL (aka Node shell). REPL stands for Read-Eval-Print-Loop. It is a quick and easy way to test simple Node.js/JavaScript code. To launch the REPL (Node shell), open command prompt (in Windows) or terminal (in Mac or UNIX/Linux) and type node as shown below. It will change the prompt to > in Windows and MAC.
  • 40. If you need to write multi line JavaScript expression or function then just press Enter whenever you want to write something in the next line as a continuation of your code. The REPL terminal will display three dots (...), it means you can continue on next line. Write .break to get out of continuity mode.
  • 41. To exit from the REPL terminal, press Ctrl + C twice or write .exit and press Enter.
  • 42. JavaScript file • 1. create a sample.js file through text editior / notepad • 2. with in sample.js file - type console.log("Hello World"); 3. Save your file again 4. Open cmd - Move to file location 5. Executing the node filename node sample.js