These are some Node JS discussion questions to deepen your understanding of NodeJS
- Differentiate between JavaScript and Node.js.
- Why Node.js is single threaded?
- How do Node.js works?
- What is package.json?
- What is an Event loop in Node.js and how does it work?
Group members: Israa, Özge, Dilara
0. Differentiate between JavaScript and Node.js.
Javascript is a programming language and Node.js is a running environment based on Javascript.
Single thread: Node JS Platform doesn’t follow the Multi-Threaded Request/Response Stateless Model. It follows the Single-Threaded with Event Loop Model. Node JS Processing model mainly inspired by JavaScript Event-based model with JavaScript callback mechanism. Because of which Node.js can handle more concurrent client requests with ease.
Node. js runs on chrome v8 engine which converts javascript code into machine code. It is highly scalable, lightweight, fast, and data-intensive.
It’s a file that holds the metadata about the npm packages and it holds the information about how to handle the project dependencies. It also gives information about the project description such as name of the project, version, author, license information etc. It is located at the root directory of the project.
The event loop is what allows Node. js to perform non-blocking I/O operations — despite the fact that JavaScript is single-threaded — by offloading operations to the system kernel whenever possible. Since most modern kernels are multi-threaded, they can handle multiple operations executing in the background. When Node.js starts, it initializes the event loop, processes the provided input script which may make async API calls, schedule timers, then begins processing the event loop.
Event loop is an endless loop, which waits for tasks, executes them and then sleeps until it receives more tasks. The event loop executes tasks from the event queue only when the call stack is empty i.e. there is no ongoing task. The event loop allows us to use callbacks and promises.The event loop executes the tasks starting from the oldest first.