3. What is Node js?
Node is not a language
Node is a server environment
Node js can connect with the database
Code and syntax is very similar to javascript but not exactly the
same.
Node js free ,open source
Node js use chrome’s v8 engine to execute code.
Node JS provides fast and highly scalable services.
The source code in node js is more consistent and clean.
It provides a large ecosystem for open source libraries.
4. Definition of node js
Node JS is an open-source and provides a cross-platform
runtime environment that helps for executing javascript
code outside the browser.
Hence it is not the framework and its not a programming
language. Most of the time node js are used as building
back end services like APIs (Web App or Mobile App).
Large companies like Netflix, Wallmart, PayPal, Uber use
the node js.
5. Why do we use Node
NodeJs is built on Google Chrome’s V8 engine, and for this
reason its execution time is very fast and it runs very quickly.
Node js is mostly used for API.
So we can connect the same databse with web app,mobile
app.
Node js is easy to understand who know javascript.
Node js is superfast for APIs.
With node and javascript ,you became the full stack
developer.
NodeJS Applications:
Complex single-page applications.
8. Advantages of node js
Less Learning Curve
Fast Development
Scalability
High Performance
Real-Time Applications
Great for Microservices
Easy Maintainability
Extensive Libraries
Vast Community
Cross-Platform
Highly Extensible
9. Node Js : Modules
What is module in node js?
Module in Node.js is a simple or complex functionality
organized in single or multiple JavaScript files which can
be reused throughout the Node.js application.
Node.js Module Types
Node.js includes three types of modules:
Core Modules/Built-in Modules
Local Modules
Third Party Modules/External Modules
10. Node.js Core Modules
Http Module:
It allows node.js applications to transfer data using HyperText
Transfer Protocol (HTTP).
This module creates an HTTP server that listens to server ports and
also gives responses back to the client.
Syntax : const http = require("http")
Distributed with node js itself
Core components of node js
Maintained by core contributors to the language
Only changes with new release of node js
11. The url module
We can use the url module for parsing.
This is a built-in module of node.js. It breaks down the url into readable
parts. It is included in the file by using the require function;
To Parse an address, use the url.parse() method. It will return a URL
object with each part of the address as its properties.
It is one of the core Node.js module.
So, we don't have to install it using NPM.
We write the following to require the url module.
Syntax :
const url = require('url');
12. The following table lists some of the
important core modules in Node.js.
Core Module Description
http http module includes classes, methods and
events to create Node.js http server.
url url module includes methods for URL
resolution and parsing.
querystring querystring module includes methods to deal
with query string.
path path module includes methods to deal with
file paths.
fs fs module includes classes, methods, and
events to work with file I/O.
util util module includes utility functions useful
for programmers.
13. Node.js Local Modules
Local modules are the modules that you define.
It makes your code easily reusable
To use local modules in your application, you need to load it using
require() function in the same way as core module.
However, you need to specify the path of JavaScript file of the module.
Syntax:
var mynewModule = require('./Log.js');
mynewModule.info('Node.js started');
14. In the above example, app.js is using log module.
First, it loads the logging module using require() function
and specified path where logging module is stored.
Logging module is contained in Log.js file in the root
folder.
So, we have specified the path './Log.js' in the require()
function. The '.' denotes a root folder.
15. Node.js External Modules
External modules are also known as third party modules and
require a package manager that maintains all the modules so that they
can be accessed with ease.
By default, node.js uses NPM [node package manager) package manager for
JavaScript runtime environment.
The third-party module can be downloaded by NPM (Node Package Manager).
Some of the most popular third-party modules are:
Express
Socket.io
Mongoose
Third party modules can be install inside the project folder or globally.
16. Below are some differences between
Node.JS and JavaScript:
Features JavaScript Node JS
Definition It is an open-source, cross-platform,
interpreted, lightweight scripting
programming language that is used
to develop dynamic and web
applications.
It is a cross-platform, open-source
JavaScript runtime environment that
allows JavaScript to be run on the
server.
Type It is a programming language. It
works in any browser that has a
proper browser engine.
It's a JavaScript interpreter and
environment with some valuable
libraries that JavaScript
programming can use separately.
Dedicated Server It is generally used on the client-
side server.
It is generally used on the server-
side.
17. Community All the JavaScript is not important to the node community. All node projects represent the JavaScript community.
Running Engines JavaScript can be run on any engine, including Spider
Monkey, V8, and JavaScript Core.
Node JS is only supported by the V8 engine, which Google
Chrome mostly uses. Any JavaScript program written with
Node JS will always be run in the V8 engine.
Used for It is designed to build network-centric applications. It's designed for data-intensive real-time applications that
run on several platforms.
Languages It's a newer version of the ECMA script that runs on
Chrome's V8 engine, which is written in C++.
It uses C, C++, and JavaScript.
Modules Few JavaScript frameworks are TypedJS, RamdaJS, etc. Lodash, express are examples of Nodejs modules. These
all modules are to be imported from npm.
Companies Uses Various companies use JavaScript like Google, Shopify,
Udacity, Sendgrid, Groupon, Okta, Instacart, etc.
Various companies use Node Js like Netflix, Hapi,
Walmart, Paypal, Linkedin, Trello, Medium, eBay, etc.