Interview Questions NodeJS MongoDB
Interview Questions NodeJS MongoDB
js Interview Questions
Node.js uses the V8 JavaScript engine, which compiles JavaScript to machine code, enhancing
performance.
Answer: The Event Loop in Node.js is a mechanism that allows the server to handle multiple client
Instead, it uses an asynchronous, non-blocking approach, where tasks are added to an event
queue.
The Event Loop continuously monitors this queue and executes tasks in a single-threaded
Answer:
res.end('Hello, World!');
}).listen(8081, () => {
});
This creates an HTTP server that listens on port 8081 and responds with "Hello, World!" when
accessed.
Answer: npm stands for Node Package Manager. It is the default package manager for Node.js
To initialize a project, use npm init, which creates a package.json file containing metadata about
Answer: MongoDB is an open-source, NoSQL database that stores data in a flexible, JSON-like
Unlike traditional RDBMS, MongoDB is schema-less, meaning it doesn't enforce a strict structure
on stored data.
It uses collections instead of tables and documents instead of rows, which allows for storing data
Answer:
use myDatabase;
- Create a Collection: Collections are created automatically when inserting the first document.
Alternatively:
db.createCollection("myCollection");
Answer:
- Create:
- Read:
- Update:
- Delete:
Answer: Indexes in MongoDB improve the speed of data retrieval operations by creating a
They are similar to indexes in relational databases and can significantly enhance query
performance.
However, excessive indexing can increase storage requirements and slow down write operations.