Node.js Flashcards
What is Node.js?
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine.
True or False: Node.js is single-threaded.
True
What is the primary use case for Node.js?
Building scalable network applications.
Fill in the blank: Node.js uses __________ for managing asynchronous calls.
event-driven architecture
What is npm?
npm is the package manager for Node.js.
True or False: Node.js can be used for front-end development.
False
What command is used to initialize a new Node.js project?
npm init
What is the purpose of the ‘require’ function in Node.js?
To import modules.
Multiple Choice: Which of the following is a core module in Node.js? A) express B) fs C) mongoose
B) fs
What does the ‘fs’ module in Node.js stand for?
File System
True or False: Node.js is ideal for I/O-heavy applications.
True
What is a callback function?
A function passed into another function as an argument that is executed after the first function completes.
Fill in the blank: Node.js uses a __________ model to handle requests.
non-blocking I/O
What is the default port for a Node.js application?
There is no default port; it can be set to any valid port.
Multiple Choice: Which of the following frameworks is built on top of Node.js? A) Angular B) React C) Express
C) Express
What is the purpose of middleware in Express.js?
Middleware functions are used to process requests and responses in the application.
True or False: Node.js can be used for database management.
True
What is the purpose of the ‘next’ function in Express middleware?
To pass control to the next middleware function.
Fill in the blank: The __________ method is used to send a response back to the client in Express.
res.send()
What does the ‘process’ object in Node.js represent?
The current Node.js process.
Multiple Choice: Which of the following is not a built-in module in Node.js? A) http B) url C) json
C) json
What is the purpose of the ‘package.json’ file?
To manage project dependencies and metadata.
True or False: Node.js supports promises and async/await for handling asynchronous code.
True
What is the event loop in Node.js?
The mechanism that allows Node.js to perform non-blocking I/O operations.
Fill in the blank: The __________ module allows you to create HTTP servers in Node.js.
http
What is the purpose of the ‘cors’ package?
To enable Cross-Origin Resource Sharing in web applications.
Multiple Choice: Which command installs a package globally in Node.js? A) npm install B) npm install -g C) npm install –global
B) npm install -g
What is a promise in JavaScript?
An object that represents the eventual completion or failure of an asynchronous operation.
True or False: You can run JavaScript code in Node.js without a web browser.
True
What does the ‘npm start’ command do?
It runs the script defined in the ‘start’ property of the package.json file.
Fill in the blank: Node.js applications are __________ by default.
event-driven
What is the purpose of the ‘dotenv’ package?
To load environment variables from a .env file into process.env.
Multiple Choice: Which HTTP method is used to update a resource? A) GET B) POST C) PUT
C) PUT
What does ‘npm audit’ do?
It checks for vulnerabilities in your project’s dependencies.
True or False: You can use Node.js for real-time applications like chat apps.
True
What is the ‘cluster’ module used for in Node.js?
To create child processes that can share server ports.
Fill in the blank: The __________ function handles errors in asynchronous code.
catch
What is the ‘body-parser’ middleware used for?
To parse incoming request bodies in a middleware before your handlers.
Multiple Choice: Which of the following is a common database used with Node.js? A) MongoDB B) MySQL C) Both A and B
C) Both A and B
What is the purpose of the ‘mongoose’ library?
To provide a schema-based solution for modeling application data with MongoDB.
True or False: Node.js supports WebSockets for real-time communication.
True
What does the ‘res.json()’ method do in Express?
It sends a JSON response.
Fill in the blank: The __________ method is used to handle GET requests in Express.
app.get()
What is the purpose of the ‘jsonwebtoken’ library?
To create and verify JSON Web Tokens (JWTs).
Multiple Choice: Which of the following is NOT a feature of Node.js? A) Event-driven B) Multi-threaded C) Non-blocking I/O
B) Multi-threaded
What is the significance of the ‘async’ keyword in JavaScript?
It allows you to write asynchronous code that looks synchronous.
True or False: Node.js has built-in support for handling file uploads.
False
What is the purpose of the ‘express-session’ middleware?
To manage sessions in Express applications.
Fill in the blank: The __________ method is used to delete a resource in Express.
app.delete()
What does the ‘crypto’ module in Node.js provide?
Cryptographic functionality that includes a set of wrappers for OpenSSL’s hash, HMAC, cipher, decipher, sign, and verify functions.
Multiple Choice: Which of the following is a framework for building RESTful APIs in Node.js? A) Angular B) Express C) Vue
B) Express
What is the purpose of the ‘nodemon’ package?
To automatically restart the Node.js application when file changes are detected.
True or False: Node.js can be used for server-side rendering of web applications.
True
What does the ‘app.listen()’ method do in Express?
It binds and listens for connections on the specified host and port.