Node Js— An Introduction
What is Node.js?
- Node.js was developed by Ryan Dahl in 2009.
- Node.js is an open source server environment that provides server side rendering in Java Script.
- It runs on all the platforms(Windows, Linux, Unix, etc) and free to install.
- It is a JavaScript based platform that is build on google chrome V8 engine.
Node.js uses asynchronous programming!!🧐
This means it eliminates the waiting, and simply continues with the next request.
Here is how Node.js works:
- It first sends the task-1.
- Till the time Task-1 is executing it takes up the another task-2.
- In this way it performs multitasking by handling multiple requests at the same time.
In Synchronous Programming,
The flow of request is straight that means
Task-1 will be executed and unless and until it will not complete no other task can be taken up.
Post completion of Task-1 only the second task will execute.
👉REPL In Node JS…
REPL stand for:
1️⃣ R — Reading the user input and parsing it into JS data structure.
2️⃣ E — Eval, means evaluate the input
3️⃣ P — Print the result
4️⃣ L — Loops the command until user abort it by pressing ctrl-C twice.
REPL is a feature of Node tat provides an environment to experiment the code like we have CMD in windows.
To start Node- e write the below command in terminal:
Various operations we can perform in REPL such as Simple Expressions, Using Variables, Multiline Expressions, Underscore Variables:
👉Commands and special keys…
The following special commands are supported by all REPL instances:
.break
: When in the process of inputting a multi-line expression, enter the.break
command (or press Ctrl+C) to abort further input or processing of that expression..clear
: Resets the REPLcontext
to an empty object and clears any multi-line expression being input..exit
: Close the I/O stream, causing the REPL to exit..help
: Show this list of special commands..save
: Save the current REPL session to a file:> .save ./file/to/save.js
.load
: Load a file into the current REPL session.> .load ./file/to/load.js
.editor
: Enter editor mode (Ctrl+D to finish, Ctrl+C to cancel).
Keep Learning✌
Thank You!!😀