Node Flashcards
What does server-side programming allow us to do?
- Deliver tailored content to individual users
- Provides access to the underlying OS features, not usually available to client-side code.
- Helps choose which content to render.
- Can be written in any programming language.
What does client-side programming allow us to do?
- Helps define content and presentation
Why do programmers use web frameworks?
Web frameworks provide solutions to common problems (e.g., session management, authentication, data management)
What is
Node.js
Node.js is an open-source runtime environment for executing JavaScript outside the browser.
Developers can write server-side code in JavaScript.
What kind of architecture is Node.js?
Single-threaded event loop architecture
What is a
Single Threaded Event Loop Architecture
One process sequentially executes incoming requests and returns a response.
What is a
Multi-Threaded Request-Response Architecture
Every incoming request executes on a separate thread.
What does the Event Loop do?
- It processes requests from the event loop sequentially.
- If a request uses blocking operations, a new thread handles them, and the next request begins.
- Otherwise, the request is processed, and a response is returned.
What is nodemon used for?
Nodemon is used to automatically restart the app when you make changes.
When we write scripts that will never terminate, how should we terminate them?
There are two options.
- Forcefully kill it (Not good)
- Exit gracefully (Good)
What is the process
module useful for?
The process
module is useful for reading arguments passed to a script from the command line.
What happens in the
Message/Callback Queue
Asynchronous operations schedule their callbacks to be executed when the Event Loop reaches the appropriate phase.
* Executed after functions in the call stack are executed.
* Callbacks are executed in order (FIFO) unless microtasks interrupt.
What is a
Promise
It is an object that resolve before a function ends are executed right after the current function.