What is NodeJS?

I’ve been studying nodejs half a year but I was just implementing APIs without understanding the foundation of tools I use.
I decided to write this post to check the foundation stuff of NodeJS! 🙂

NodeJS is an runtime environment that is built on V8…


This content originally appeared on DEV Community and was authored by DEV Community

I've been studying nodejs half a year but I was just implementing APIs without understanding the foundation of tools I use.
I decided to write this post to check the foundation stuff of NodeJS! :)

NodeJS is an runtime environment that is built on V8 engine ( which compiles javascript codes into native machine codes).

NodeJS has some special features like event-driven, non-blocking(asynchronous) programming.

  1. What is Event driven programming? > Event driven programming in NodeJS means that events occurred by mouse and network communication like request and response are handled via callback functions. here's some example.

Mouse event

const card = document.getElementById('card');
canvas.addEventListener('click', eventHandler);

Network event

app.get('/', (req, res) => {
  res.send("hello world");
});

You can see that those events are handled through callback
functions. Events are processed by Event Loop. and the Event loop
processes the Phases and these Phases have Queues. Event loops
will choose phases with Round Robin scheduling method.

A round robin is an arrangement of choosing all elements in a group equally in some rational order, usually from the top to the bottom of a list and then starting again at the top of the list and so on.

  1. Non-Blocking
    NodeJS supports a single thread programming. This means every process in NodeJS lives in a thread. But since it's single thread if the first process is working long time then next processes should wait until the first process ends. But NodeJS is Non-Blocking. So, Even tho the first process didn't end yet, next processes can be executed. This will make your app still working even tho there's heavy data being processed.

  2. Cross-Platform runtime environment.
    Your Nodejs codes will work on different operating systems like OSX, MacOS, Windows!

If you have some advice, please share it via comments!
Thanks for reading my post!


This content originally appeared on DEV Community and was authored by DEV Community


Print Share Comment Cite Upload Translate Updates
APA

DEV Community | Sciencx (2022-03-14T09:14:53+00:00) What is NodeJS?. Retrieved from https://www.scien.cx/2022/03/14/what-is-nodejs-2/

MLA
" » What is NodeJS?." DEV Community | Sciencx - Monday March 14, 2022, https://www.scien.cx/2022/03/14/what-is-nodejs-2/
HARVARD
DEV Community | Sciencx Monday March 14, 2022 » What is NodeJS?., viewed ,<https://www.scien.cx/2022/03/14/what-is-nodejs-2/>
VANCOUVER
DEV Community | Sciencx - » What is NodeJS?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/03/14/what-is-nodejs-2/
CHICAGO
" » What is NodeJS?." DEV Community | Sciencx - Accessed . https://www.scien.cx/2022/03/14/what-is-nodejs-2/
IEEE
" » What is NodeJS?." DEV Community | Sciencx [Online]. Available: https://www.scien.cx/2022/03/14/what-is-nodejs-2/. [Accessed: ]
rf:citation
» What is NodeJS? | DEV Community | Sciencx | https://www.scien.cx/2022/03/14/what-is-nodejs-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.