⚡⚡Introduction to Nodejs: Part-1⭐⭐

⚡⚡Introduction to Nodejs: Part-1⭐⭐

Nodejs Series(Learn Nodejs from Scratch)

Introduction to Nodejs 🙂

Do you ever wondered why developers used nodejs.

🤔What is the need for nodejs ?
🤔Why it came into the programming world?
🤔Why is it so much popular?
🤔What other things are there in the market which does the same job as nodejs ?

Text

Don't worry, you will get all the answers after you end reading this blog.

Starting with this line

" Node.js® is an open-source, cross-platform JavaScript runtime environment. "

Yes, firstly it is not a programming language. It is a runtime environment to code javascript. There was a time when javascript was locked up inside the browser, it can do client-side scripting only but with time, it came out from the lockup and was used in our local computers. This can only be done with the power of runtime environments, one of them is nodejs.

Sounds Interesting right !!! Text

So now you got the point that to run the javascript in our local editor on the server side, we need nodejs.

But why is it so popular?

📌 Nodejs is mostly used for handling and creating APIs, which runs smoothly and fast using Nodejs.
📌It is open source and it used chrome v8 engine to execute javascript code so it works very fast.
📌Using Nodejs, we can connect the same database with the web, android, and IOS devices.

OK, so you got some outside features of nodejs and why is it popular? Now, what are alternatives to nodejs?

👉ASP.net
👉Ext Js
👉Elixir
👉 Deno

Nodejs application uses asynchronous programming and works as single-threaded.

When nodejs performs any I/O operations like reading files or interacting with databases, then it doesn't halt any thread and waits for a response. It just resumes the action as the response gets received. This allows nodejs to handle multiple connections from a single server and it handles it very perfectly.

Features of Nodejs 💪

  1. It can produce dynamic pages and we can create a full-fledged website using template and nodejs.
  2. It can create, read, delete, update, and find one or more than one files on the server.
  3. It can interact with the database and helps to do CRUD operations from and to the database.
  4. Application created using nodejs works on all devices including mobile, IOS, and web.

Node js Modules 📝

These are some functionalities that nodejs provides and used in our javascript code either individually or globally. Just like javascript libraries, you can import all these functions.

These modules give you the power of reusability and break your complex code into smaller chunks. Node.js implements the standard of the CommonJS module. CommonJS is a group of volunteers who define JavaScript standards for web servers, desktops, and console applications.

Types of Modules 🙄

1. Core Modules

These modules are present inside nodejs. You can easily use it by the 'require' function. As nodejs starts, all these modules are loaded automatically.

Syntax

// let module = require('module_name');

const fs= require('fs');
// This module deals with the file systems in nodejs and you can Create, read, update and delete using this module.
require function returns javascript types depending on the usecase by the user.

Some of the important used Core Modules are http, fs, path, process, os, url and many more.

2. Local Module

The modules which you can also create it and use in different files are local modules.

exports.add = function (x, y) { 
    return x + y; 
}; 
// file name is add.js
let performAdditon = require('./add');
performAddition.add(2,3); //5

// file name is index.js

3. Third-Party Modules( External Modules)

Modules that are available online and are installed using the npm are called third-party modules. Examples of third-party modules are express, mongoose, etc.

npm install express

You can check it in the package.json file. Don't worry if you don't know about this file. It will get covered in the next blog where we will start our first server and check in the browser.

Text

Thank you Guys 😍😍 for giving your valuable time for reading this blog. Let's catchup next blog.