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: Yaman, Emine, Mehmet, İrem
QUESTIONS
Javascript is a programming language but NodeJS is a Javascript runtime environment.
Javascript can only be run in the browsers while we can run Javascript outside the browser with the help of NodeJS.
JS used in client side while NodeJS is used on the server side.
Why nodejs, JavaScript is single threaded?
Similarly, within the call stack, whenever a line of code gets inside the call stack it gets executed and move out of the stack. In this way, JavaScript is a single-thread language because of only one call stack , but we can achieve multithreading by generating multiple nodes or Node.js V8 engines which in isolation are single-threaded. It is still correct to say Node.js is not multi-threaded.
Node.js basically works on two concept
Asynchronous
Non-blocking I/O
Non-blocking I/o: Non-blocking i/o means working with multiple requests without blocking the thread for a single request. I/O basically interacts with external systems such as files, databases. Node.js is not used for CPU-intensive work means for calculations, video processing because a single thread cannot handle the CPU works.
Asynchronous: Asynchronous is executing a callback function. The moment we get the response from the other server or database it will execute a callback function. Callback functions are called as soon as some work is finished and this is because the node.js uses an event-driven architecture. The single thread doesn’t work with the request instead it sends the request to another system which resolves the request and it is accessible for another request.
3)A package. json is a JSON file that exists at the root of a Javascript/Node project. It holds metadata relevant to the project and it is used for managing the project's dependencies, scripts, version and a whole lot more.