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

PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
PPTX
Beginners Node.js
PPTX
Advanced Web Technology.pptx
PPTX
PDF
Intro to node.js - Ran Mizrahi (27/8/2014)
PDF
Intro to node.js - Ran Mizrahi (28/8/14)
PDF
FITC - Node.js 101
PPTX
What is Mean Stack Development ?
Server Side Web Development Unit 1 of Nodejs.pptx
Beginners Node.js
Advanced Web Technology.pptx
Intro to node.js - Ran Mizrahi (27/8/2014)
Intro to node.js - Ran Mizrahi (28/8/14)
FITC - Node.js 101
What is Mean Stack Development ?

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

PDF
Isomorphic JavaScript with Nashorn
PPTX
PPTX
AJppt.pptx
PPTX
Kalp Corporate Node JS Perfect Guide
PDF
Javascript pdf for beginners easy levell
PPTX
Advance Java Topics (J2EE)
PDF
Java ScriptingJava Scripting: One VM, Many Languages
PDF
Node.js 101 with Rami Sayar
PDF
An introduction to Node.js
PDF
Isomorphic JavaScript: #DevBeat Master Class
PDF
Node js internal
PPTX
introduction to node.js
PPTX
Unit 1 Express J for mean stack and mern
PDF
8.-Javascript-report powerpoint presentation
PDF
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
PDF
PDF
Real time web
PDF
Tech io nodejs_20130531_v0.6
Isomorphic JavaScript with Nashorn
AJppt.pptx
Kalp Corporate Node JS Perfect Guide
Javascript pdf for beginners easy levell
Advance Java Topics (J2EE)
Java ScriptingJava Scripting: One VM, Many Languages
Node.js 101 with Rami Sayar
An introduction to Node.js
Isomorphic JavaScript: #DevBeat Master Class
Node js internal
introduction to node.js
Unit 1 Express J for mean stack and mern
8.-Javascript-report powerpoint presentation
Node Js Non-blocking or asynchronous Blocking or synchronous.pdf
Real time web
Tech io nodejs_20130531_v0.6
Ad

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

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

Recently uploaded (20)

PDF
Auditboard EB SOX Playbook 2023 edition.
PDF
Examining Bias in AI Generated News Content.pdf
PPTX
Internet of Everything -Basic concepts details
PDF
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
PDF
Rapid Prototyping: A lecture on prototyping techniques for interface design
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Ensemble model-based arrhythmia classification with local interpretable model...
PDF
Decision Optimization - From Theory to Practice
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
PDF
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
Human Computer Interaction Miterm Lesson
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
A symptom-driven medical diagnosis support model based on machine learning te...
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PDF
Altius execution marketplace concept.pdf
Auditboard EB SOX Playbook 2023 edition.
Examining Bias in AI Generated News Content.pdf
Internet of Everything -Basic concepts details
“The Future of Visual AI: Efficient Multimodal Intelligence,” a Keynote Prese...
Rapid Prototyping: A lecture on prototyping techniques for interface design
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Ensemble model-based arrhythmia classification with local interpretable model...
Decision Optimization - From Theory to Practice
Connector Corner: Transform Unstructured Documents with Agentic Automation
Transform-Your-Supply-Chain-with-AI-Driven-Quality-Engineering.pdf
IT-ITes Industry bjjbnkmkhkhknbmhkhmjhjkhj
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Human Computer Interaction Miterm Lesson
Presentation - Principles of Instructional Design.pptx
Dell Pro Micro: Speed customer interactions, patient processing, and learning...
Advancing precision in air quality forecasting through machine learning integ...
A symptom-driven medical diagnosis support model based on machine learning te...
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Altius execution marketplace concept.pdf

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