MERN Stack Flashcards

(40 cards)

1
Q

What is MongoDB?

A

MongoDB is a NoSQL database that stores data in a flexible, JSON-like format called BSON.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the key features of MongoDB?

A

Key features include scalability, flexible schema, high performance, indexing, replication, and support for sharding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a document in MongoDB?

A

A document is a single record in MongoDB, stored as a BSON object similar to a JSON object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a collection in MongoDB?

A

A collection is a group of MongoDB documents, analogous to a table in relational databases but with a dynamic schema.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between MongoDB and a relational database?

A

MongoDB is a NoSQL database with a flexible schema and document-based storage, while relational databases use fixed schemas and tables with rows and columns.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an index in MongoDB?

A

An index in MongoDB is a special structure that improves the speed of data retrieval operations on a collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is replication in MongoDB?

A

Replication is the process of synchronizing data across multiple servers to ensure high availability and redundancy.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is recording in MongoDB?

A

Recording seems to be a typo; it likely refers to ‘sharding’ or ‘replication.’ Assuming replication: it syncs data across servers for reliability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does the aggregation framework work in MongoDB?

A

The aggregation framework processes data through a pipeline of stages (e.g., filter, group, sort) to transform and analyze data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you perform a backup and restore in MongoDB?

A

Use mongodump to create a backup and mongorestore to restore data from the backup.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Express.js?

A

Express.js is a minimal and flexible Node.js web application framework that simplifies building APIs and web servers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the main features of Express.js?

A

Main features include middleware support, routing, HTTP utility methods, and easy integration with templating engines.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you create a simple server using Express.js?

A

Use require(‘express’), create an app with express(), and start it with app.listen(port), e.g., app.get(‘/’, (req, res) => res.send(‘Hello’)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is middleware in Express.js?

A

Middleware are functions that have access to the request and response objects, used for tasks like logging, authentication, or parsing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you define routes in Express.js?

A

Define routes using app.get(), app.post(), etc., with a path and callback, e.g., app.get(‘/users’, (req, res) => res.send(‘Users’)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you handle errors in Express.js?

A

Use a middleware with four parameters (err, req, res, next) to catch and handle errors, e.g., app.use((err, req, res, next) => res.status(500).send(err)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is the role of the next function in middleware?

A

The next function passes control to the next middleware function in the stack, allowing sequential processing.

18
Q

How do you handle form data and file uploads in Express.js?

A

Use middleware like body-parser for form data and multer for file uploads, configuring them to parse req.body or req.files.

19
Q

How can you manage different environments in an Express.js application?

A

Use environment variables with process.env, and switch configurations (e.g., dev, prod) using a config file or package like dotenv.

20
Q

What are some common security best practices when using Express.js?

A

Use Helmet for headers, sanitize inputs, enable CORS appropriately, use HTTPS, and validate/escape data to prevent attacks.

21
Q

What is React.js?

A

React.js is a JavaScript library for building user interfaces, especially single-page applications, using a component-based architecture.

22
Q

What are the main features of React.js?

A

Main features include virtual DOM, component reusability, JSX, hooks, and efficient updates via a diffing algorithm.

23
Q

What is JSX?

A

JSX is a syntax extension for JavaScript that allows writing HTML-like code within React components, which is transpiled to JavaScript.

24
Q

What are components in React.js?

A

Components are reusable building blocks in React that encapsulate UI and logic, either as functional or class-based entities.

25
What is the difference between functional and class components?
Functional components are simpler, hook-based functions, while class components use ES6 classes with lifecycle methods.
26
What is state in React.js and how is it used?
State is an object that holds data specific to a component, managed with useState in functional components or this.setState in class components.
27
What are props in React.js and how do they differ from state?
Props are immutable data passed to components from parents, while state is mutable data managed within the component.
28
What is the virtual DOM and how does React use it?
The virtual DOM is a lightweight copy of the real DOM. React uses it to compute differences and update the real DOM efficiently.
29
What are React hooks and name a few commonly used hooks?
Hooks are functions to use state and lifecycle features in functional components. Common hooks: useState, useEffect, useContext.
30
How do you manage side effects in React.js?
Use the useEffect hook to handle side effects like data fetching, subscriptions, or DOM manipulations after render.
31
What is Node.js?
Node.js is a runtime that allows executing JavaScript on the server side, built on Chrome's V8 engine.
32
What are the main features of Node.js?
Main features include non-blocking I/O, event-driven architecture, single-threaded model, and a rich ecosystem via npm.
33
How does Node.js handle asynchronous operations?
Node.js uses an event loop, callbacks, promises, and async/await to handle asynchronous operations non-blockingly.
34
What is the event loop in Node.js?
The event loop is a mechanism that allows Node.js to perform non-blocking I/O operations by offloading tasks to the system kernel.
35
What are streams in Node.js and how are they used?
Streams are objects for handling data in chunks, used for reading/writing files, network communications, and processing large datasets efficiently.
36
What is the difference between process.nextTick() and setImmediate()?
process.nextTick() runs before I/O events in the next iteration, while setImmediate() runs after I/O events in the next iteration.
37
How do you handle errors in Node.js?
Use try-catch for synchronous code, handle errors in callbacks/promises, or use a global error handler with process.on('uncaughtException').
38
What are some common use cases for Node.js?
Common use cases include real-time apps (chat), APIs, microservices, streaming, and server-side rendering.
39
What are modules in Node.js and how do you use them?
Modules are reusable code units. Use require() to import (CommonJS) or import/export (ES6) with a package.json configuration.
40
How do you manage package dependencies in a Node.js project?
Manage dependencies with a package.json file, using npm install to add packages and npm update to keep them current.