Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created May 7, 2022 07:17
Show Gist options
  • Save halitbatur/5d89be2e3fe15bac3fa2fe349c7de91d to your computer and use it in GitHub Desktop.
Save halitbatur/5d89be2e3fe15bac3fa2fe349c7de91d to your computer and use it in GitHub Desktop.
Node JS discussion questions

Node JS discussions

These are some Node JS discussion questions to deepen your understanding of NodeJS

  1. Differentiate between JavaScript and Node.js.
  2. Why Node.js is single threaded?
  3. How do Node.js works?
  4. What is package.json?
  5. What is an Event loop in Node.js and how does it work?
@khatibAmjad
Copy link

Team : Amjad - Mohammad Sheikh - Huzefye Abdullahoglu - Hamza

Differentiate between JavaScript and Node.js.

In web development: Javascript is executed in browser (at client side), on the other hand, Node.js designed for backend applications and Apis

Node is an environment written in C, C++, and JavaScript, and it is built on the open-source V8 JavaScript engine which also powers JS in browsers such as Google Chrome. As V8 supports new features in JavaScript, they are incorporated into Node.
runs on a server, used to make
Backend For Social Media Networking
Single-Page Applications
Chat Applications
Data Streaming
IoT Applications

Why Node.js is single threaded?
Node.js is relayed on javascript, so because JS is single threaded node.js will do so
(The single-threaded, event-driven architecture makes it very easy for handling multiple connections. An additional thread is created with each new request with Most of the popular programming languages but with Node that’s not the case.)

How does Node.js work?
It work by using the v8 engine which is the same engine that javascript uses , and node js been written with c++ language so that we can run node js on our computer as a server

What is package.json?
Package.json is a file which contain all dependencies and libraries that we install using the node package manger (npm) , so that we don’t have to upload all library to the host when we finish the program

What is an Event loop in Node.js and how does it work?
An event loop is an event-listener which functions inside the NodeJS environment and is always ready to listen, process, and output for an event. An event can be anything from a mouse click to a keypress or a timeout
Event loop waits for tasks, executes them and then sleeps until it receives more tasks. it executes tasks from the event queue only when the call stack is empty.
Sourece :
https://www.tatvasoft.com/outsourcing/2021/09/what-can-we-do-with-node-js.html

@cbaksakal
Copy link

  1. JavaScript is a programming language. On the other hand, nodeJS is an environment that uses JavaScript to make some jobs easier like I/O, networking etc. NodeJS also acts as an interpreter for JavaScript.
  2. NodeJS uses event loop model with a single thread. Async operations are queued in the event loop and callbacks are called whenever necessary.
  3. First, a request is made by the client. Then, it is added to event queue. Then we process this event. If it is a blocking one, we pass it to worker threads and it makes its way to event loop. Otherwise, it is executed directly.
  4. When you create a nodeJS project, package.json file is automatically created on the same directory. It holds metadata, dependencies and other information about the project.
  5. An event loop is an infinite loop that waits for tasks, execute them and then sleep until the next event. Event loop accepts the tasks from the event queue and allows NodeJS to perform non-blocking I/O operations and etc.

Room 6
Rasha Bsirini
Sobhan Shams
Cengiz Aksakal

@awiednoor
Copy link

These are some Node JS discussion questions to deepen your understanding of NodeJS
Differentiate between JavaScript and Node.js.
Js is a language , node js is runtime environment built in this language along with C/C++.
Why Node.js is single threaded?
Node.js use Single Threaded Event Loop Model architecture to handle multiple concurrent clients Which is inspired by js event model with js callback mechanism.
How do Node.js works?
It handles requests and responses from and to the server with a single thread, It manages files on the server
It’s build on the v8 engine which allows it to run js outside the browser
Node.js works on two concepts, Asynchronous and Non-blocking I/O
What is package.json?
It’s a json file that holds information about the project and the list of dependencies with their versions.
What is an Event loop in Node.js and how does it work?
An event loop is an event-listener which functions inside the NodeJS environment
Event loops allow node.js to be non-blocking because events are used to perform the operations in one thread.
As a single-threaded application, Node.js can support concurrency through the concept of events and callbacks. Because Node.js APIs are all asynchronous, they use async function calls to maintain concurrency. Node uses observer pattern. When a task is completed, the node thread fires the corresponding event which signals the event-listener function to run.
Event queue, the requests are placed in the event queue in a single thread, then the event loop takes each event and run the callback function related to this event.

Noor Awied, Nilay aydin & Rama Shaban

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment