Node 101 Flashcards
What is NodeJS and why would you use it in web development
NodeJS is a runtime environment that allows the execution of Javascript code on the server side. It is built on the V8 JavaScript runtime and is designed for building scalable network applications. Nodejs is particularly well suited for web development because it enables build fast, scalable, and real-time applications using Javascript, which traditionally was limited to client side scripting in the browers
Explain the event-driven architecture of NodeJS
In the event-driven architecture of Nodejs It utilizes the event loop to trigger associated event handlers when an event occurs. The event loop then pushes the corresponding registered callback to the call stack for execution. The entire process is carried in an asynchronous and non-blocking manner.
How does Nodejs handle asynchronous operations
Asynchronous events like Network request, file I/O are initiated and the associated callback is registered for execution upon completion
What is NPM, and how do you use it in a Nodejs project.
Npm is a package manager for Nodejs, used to manage and install dependencies for a Nodejs project. It also provides a registry for public and private packages. Besides installing and managing packages, it can also be used to run scripts defined in the package json file.
Describe the purpose of the package.json file in a nodejs project
The package.json file in a Nodejs project serves as a manifest that includes Metadata about the project, such as its name, version, dependencies, running scripts, and configuring projects
What is the role of the require function in nodejs
The require function is used to include and use external modules in a program. It’s a common way to organize and reuse code in Javascript. The require returns the exports of the specified modules allowing you to use their functionality
Explain the concepts of middleware in a nodejs application
Middleware in Nodejs is a module of function that has access to the response, request, and next Middleware function in the request-response cycle. It’s used to perform tasks such as logging, authentication or modifying the request/response object before calling the next Middleware function
How do you handle errors in a Nodejs Application
Errors in Nodejs can be handled with a try catch block, callbacks , and promises. Nodejs also has a built-in process.on(uncaughtException) event for catching unhandled exceptions
What is the difference between setImmediately and process.nextTick()
They are both used to schedule callbacks to be executed on the next event loop iteration. SetImmediately are executed after event I/O whiles process.nextTick() is executed before I/O events.
How does nodejs handle concurrency
Nodejs handles concurrency through its event-driven, non blocking IO model. It utilizes the event loop to process and execute asynchronous tasks without blocking the execution of the other tasks