Basic Questions
What is Node.js?
It is an environment in which you can execute your JavaScript code on the server-side.
What are the characteristics of Node.js?
Asynchronous and Event-based
Non-blocking I/O
Multiple operation in-built libraries (HTTP, File System)
What is an event loop in Node.js?
An event loop is a mechanism that makes it easier to deal with asynchronous programming through the use of callbacks when I/O and other actions are done.
What is NPM?
Node Package Manager is an abbreviation that stands for NPM and acts as the package manager of Node.js.
What’s the difference between require() and import?
The require function is applied in CommonJS modules, whereas import is utilized in ES6 modules.
Intermediate Questions
How does Node.js perform asynchronous operations?
Through callbacks, promises, and async/await functions.
What are Streams in Node.js?
They are objects that help in reading/writing data chunk by chunk without loading all of the data into the memory.
SetImmediate vs Process.nextTick?
setImmediate() will execute the code when the event loop has completed its execution, while process.nextTick() executes the code just before the event loop execution.
What are the global variables in Node.js?
Global variables in Node.js are: __dirname, __filename, Buffer, global.
Advanced Questions
Why do you need clustering in Node.js?
Clustering helps to have several instances of your app to take advantage of multiple cores of the CPU.
How does Node.js handle memory?
With the help of garbage collection in V8.
Node.js: What is Middleware?
Middleware is the implementation of the function in the request-response process.
How to optimize Node.js application work?
Clustering, caching, load balancing.
Optimize database queries.
Node.js: What is The Difference Between Spawn() And Exec() ?
Spawn() creates a process with streams whereas exec() captures the total output.
MongoDB Interview Questions
Basic Questions
What is MongoDB?
It is a NoSQL database that stores information in a flexible form of BSON.
What are the main features of the MongoDB database?
No schema database
Performance
Scalability through sharding
Powerful query language
What is the difference between SQL and NoSQL database?
In the case of SQL database, the structured data is stored with schemas while in the NoSQL database, there is no schema and unstructured data is stored.
What is collection in MongoDB?
Collection in MongoDB refers to a set of MongoDB documents and can be compared to tables in relational databases.
What is a document in MongoDB?
It is an entry in MongoDB database stored in JSON like structure.
Intermediate Questions
How is high availability maintained in MongoDB?
Using replica sets.
Sharding in MongoDB
Sharding refers to the segmentation of data in various servers.
What does an index refer to in MongoDB?
An index makes the querying of data faster.
What does aggregation mean in MongoDB?
Aggregation is an operation performed on the data in form of operations like filtering, grouping, and sorting.
How are transactions carried out in MongoDB?
Transactions in MongoDB became available in version 4.0 and later versions.
Advanced Questions
Explain the differences between embedded and referenced relationships in MongoDB.
Embedded means storing information in one document, whereas referenced means storing information in different documents through references.
How do you model data in MongoDB?
By comprehending the relationships, use cases, and structure of the data.
Define MongoDB Atlas and Compass.
MongoDB Atlas is the cloud database of MongoDB. MongoDB Compass is a user interface tool for MongoDB.
Explain the concept of capped collections in MongoDB.
Collections with limited sizes whose data is overwritten automatically once the capacity is reached.
How do you perform backups in MongoDB?
With the help of mongodump and mongorestore.
Express.js Interview Questions
Basic Questions
Express.js is?
Express.js is a framework used to create web and mobile applications using Node.js.
Features of Express.js
Middleware
Routing
Templating engines
RESTful API
What is middleware in Express.js?
Middleware is a function called as part of the request response cycle.
How can Express.js be installed?
Functions that are called as part of the request response cycle.
What is the difference between app.use() and app.get() in Express.js?
app.use() is for the middleware and app.get() is for the GET requests.
Intermediate Questions
How do you solve 404 errors in Express.js?
javascript
Copy code
app.use(function(req, res) {
res.status(404).send("Page Not Found");
What is the difference between req.params and req.query?
The req.params is used for route parameters, and req.query is used for query string parameters.
How do you enable CORS in Express?
Use the cors middleware:
javascript
Copy code
const cors = require('cors');
app.use(cors());
How do you deal with templates in Express.js?
Define the view engine and render templates:
javascript
Copy code
app.set('view engine', 'ejs');
const cors = require('cors');
app.use(cors());
What is routing in Express.js?
Routing involves URL routing and handling of HTTP requests.
Advanced Questions
What are some techniques for increasing the security of your Express application?
Helmet, HTTPS, rate limiting, sanitizing user input.
How does synchronous middleware differ from asynchronous middleware in Express.js?
Synchronous middleware executes immediately, whereas asynchronous runs using next() or await.
javascript
Copy code
app.use((err, req, res, next) => {
res.status(500).send("Internal Server Error");
What is a subrouter in Express.js?
It’s a small router that enables you to keep your routes in different files.
How do you upload files in Express.js?
Multer middleware.
Author:
Sonal Vanarse
Related Links:
Resume Tips For Software Developers
Do visit our channel to know more: SevenMentor
Sonal Vanarse
Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.