Day 16 of 100days of code.

Day 16 of 100days of code.

ยท

2 min read

Fundamentals of nodeJS

Understanding the architectures of nodeJS runtime

What is process

A process put simply, is just a program which is currently executing. For example when we open up a calculator app on our computer, a process called calc.exe will be created for that calculator program to facilitate it's execution and we can see this process in the task manager after the program has been opened. Same way when we run a nodeJS application on a computer, a node process will be opened for that node application which will run on that computer. We can access this process from our node application using a process variable.

What is a thread

A thread is responsible for executing a program code in process. by default every process has one main thread.

Event loop in nodeJS

Event loop is where all the call back functions wait to be executed. In simple words, the event loop receives events each time something important happens. Event loop makes asynchronous programming possible in nodeJS.
Lets see some practical examples of the workings of the event loop.๐Ÿ‘‡๐Ÿผ

The event loop is simply asynchronous programming.

Lets see the output in the console๐Ÿ‘‡๐Ÿผ

Notice from the console output, the callback function was executed last even though the code was written second in the code base. This is a practical behavior of event loops in nodeJS.

That's all for this lesson.

Next: What is Express JS

See you soon๐Ÿ˜Š๐ŸซกโœŒ๐Ÿผ...

ย