MERN (Mongo Express React Node) Interview Questions & Ans
MERN (Mongo Express React Node) Interview Questions & Ans
Gaurav Pandey
Swipe>>
2- How many indexes does MongoDB create by default for a new
collection?
By default, MongoDB creates a unique index on the _id field during the creation
of a collection. The _id index prevents clients from inserting two documents with
the same value for the _id field.
Gaurav Pandey
Swipe>>
5- How can you achieve primary key - foreign key relationships in
MongoDB?
MongoDB transactions can exist only for relatively short time periods. By default,
a transaction must span no more than one minute of clock time. This limitation
results from the underlying MongoDB implementation. MongoDB uses MVCC,
but unlike databases such as Oracle, the “older” versions of data are kept only in
memory.
● You cannot create or drop a collection inside a transaction.
● Transactions cannot make writes to a capped collection
● Transactions take plenty of time to execute and somehow they
can slow the performance of the database.
● Transaction size is limited to 16MB requiring one to split any that
tends to exceed this size into smaller transactions.
Gaurav Pandey
Swipe>>
● Subjecting a large number of documents to a transaction may
exert excessive pressure on the WiredTiger engine and since it
relies on the snapshot capability, there will be a retention of large
unflushed operations in memory. This renders some
performance costs on the database.
Gaurav Pandey
Swipe>>
2- Express Interview Questions And Answers
DEBUG=express:*
node app.js
On Windows:
set DEBUG=express:*
node app.js
Gaurav Pandey
Swipe>>
3- Serving static files in Express.js?
app.use(express.static('public'))
app.use('/static', express.static(path.join(__dirname, 'public')));
console.log(result)
})
})
Gaurav Pandey
Swipe>>
5- Error handling in Express.js?
When someone passes parameters in URL (i.e. Parametrized URL), this routing
phenomenon is called dynamic routing.
Gaurav Pandey
Swipe>>
7- What is routing and how routing works in Express.js?
Route Syntax:
app.METHOD(PATH, HANDLER);
Where:
Gaurav Pandey
Swipe>>
3- React js Interview Questions And Answers
1- What is React?
If the component needs state or lifecycle methods then use class component
otherwise use function component. However, from React 16.8 with the addition
of Hooks, you could use state , lifecycle methods, and other features that were
Gaurav Pandey
Swipe>>
only available in class component right in your function component. *So, it is
always recommended to use Function components, unless you need a React
functionality whose Function component equivalent is not present yet, like Error
Boundaries *
Props are inputs to components. They are single values or objects containing a
set of values that are passed to components on creation using a naming
convention similar to HTML-tag attributes. They are data passed down from a
parent component to a child component.
Gaurav Pandey
Swipe>>
For example, let us create an element with reactProp property:
<Element reactProp={'1'} />
This reactProp (or whatever you came up with) name then becomes a property
attached to React's native props object which originally already exists on all
components created using React library.
props.reactProp
Both props and state are plain JavaScript objects. While both of them hold
information that influences the output of render, they are different in their
functionality with respect to components. Props get passed to the component
similar to function parameters whereas state is managed within the component
similar to variables declared within a function.
The callback function is invoked when setState is finished and the component
gets rendered. Since setState() is asynchronous the callback function is used for
any post action.
Note: It is recommended to use the lifecycle method rather than this callback
function.
Gaurav Pandey
Swipe>>
setState({ name: 'John' }, () => console.log('The name has updated and component
re-rendered'))
The ref is used to return a reference to the element. They should be avoided in
most cases, however, they can be useful when you need direct access to the
DOM element or an instance of a component.
The Virtual DOM (VDOM) is an in-memory representation of the Real DOM. The
representation of a UI is kept in memory and synced with the "real" DOM. It's a
step that happens between the render function being called and the displaying of
elements on the screen. This entire process is called reconciliation.
11- What is the difference between Shadow DOM and Virtual DOM?
Gaurav Pandey
Swipe>>
The Shadow DOM is a browser technology designed primarily for scoping
variables and CSS in web components. The Virtual DOM is a concept
implemented by libraries in JavaScript on top of browser APIs.
Gaurav Pandey
Swipe>>
4- Node js Interview Questions And Answers
The difference between Node.js and Ajax is that Ajax (short for Asynchronous
Javascript and XML) is a client-side technology, often used for updating the
contents of the page without refreshing it. While,Node.js is Server Side
Javascript, used for developing server software. Node.js does not execute in the
browser but by the server.
Gaurav Pandey
Swipe>>
An online repository for Node.js packages
Command-line utility for installing packages, version management and
dependency management of Node.js packages
Scalable network programs can be developed easily by Node.js and if you like to
know why we should use Node, js then due to the below-listed advantages it is
usually used by the organizations:
- Great concurrency is yielded by Node.js
- Every feature of Node.js is asynchronous
- It is never blocked
- It is quite faster
- A unified programming language and data type is offered by this
In Node.js stream allow users to read data from the source and o write data to a
destination in a continuous process.
They are just an object and the following four types of streams are there in
Node.js they are:
Gaurav Pandey
Swipe>>
● To provide read operation
● To provide a write operation
● To provide both read and write operation
● A duplex stream form that can perform computations as per available
data.
npm stands for Node Package Manager. Following are the two main
functionalities of npm:
Online repositories for node.js packages/modules which are searchable on
search.nodejs.org
Command-line utility to install packages, do version management and
dependency management of Node.js packages.
Node.js core modules follow a standard signature for their callback handlers and
usually the first argument is an optional error object. And if there is no error, then
the argument defaults to null or undefined.
Gaurav Pandey
Swipe>>
Reference:
https://github.com/learning-zone/mongodb-interview-questions
https://www.fullstacktutorials.com/interviews/top-10-express-js-interview-questions-answers-30.html
https://github.com/sudheerj/reactjs-interview-questions
https://github.com/learning-zone/nodejs-interview-questions
Gaurav Pandey
Swipe>>