MEAN Stack Interview Questions and Answers for freshers & Experienced.
What is MEAN Stack?
The term “MEAN” stack is an abbreviation that a combination of MongoDB, Expressjs, Angularjs, and Nodejs technologies. It is mainly used to develop complex websites, Mobile Apps development, and desktop Applications. It is also called as Full stack (Both Front End and Back End) JavaScript. This particular stack helps developers with an end-to-end framework for building dynamic web applications.
Can you define Stack?
Stack is generally a combination of programming languages and software products or technologies. Development stack is also divided into two categories known as technology stack and application stack.
Can you explain each letter of M-E-A-N?
MEAN is used for complex development because Mongo DB, Express and Node.JS are based on JavaScript technology and Angular is based on TypeScript.
M- MongoDB: – It is popular database server that stores data structures in a binary JSON format.
E-ExpressJS: – It is a backend web application JavaScript framework. It is based on Nodejs.
A-Angular: – it is a front-end web application framework. this framework allows for rapid development of dynamic, single page web applications.
N-Nodejs: – It is JavaScript runtime environment. It is mainly used for developing high performing and scalable server-side applications.
When should you choose MEAN Stack for your project?
MEAN stack is an open-source full-stack JavaScript framework and is made up of features that are free to use. MEAN stack development is high in speed and reusable due to the non-blocking architecture of Node.js. It provides developers with the perfect platform to build dynamic applications. It can be used in different types of applications:
For Real-time applications (social media networks, chats, and forums).
Multimedia streaming Applications
What do you know more about Mongo DB?
MongoDB is an open source, document-oriented database management system. It is a NoSQL Database. It is a cross-platform, NoSQL database with flexibility, high-performance, and high scalability that allows seamless indexing and querying. MongoDB is cost-effective and can be used to move the client and server-side data. The main role of MongoDB in the MEAN stack is to store the application’s data. It is used by your back-end application to store its data as JSON documents.
Why Express framework is used in MEAN Stack?
Express.JS is free and open-source backend web application framework that has a considerably lightweight server. It enables speed, facilitates secure applications and manages the interaction between the front-end and database. Express.js is an excellent error handler which provides easy templates to speed up your development. In MEAN stack Express.JS helps in managing HTTP requests, rendering basic routing, and producing API (Application Program Interface).
Can you explain Nodejs?
Node.js is an open-source JavaScript framework that uses asynchronous events to process multiple connections simultaneously. This feature of Node.js helps the framework to use a single thread architecture, providing a smooth user experience across multiple connections. In MEAN Stack, it enables developers to develop highly functional back-end applications with the JavaScript running on the server.
What is Inversion of Control?
Inversion of control: It is a broad term but for a software developer it’s most commonly described as a pattern used for decoupling components and layers in the system.
Can you explain CORS and how to enable one?
CORS stands for cross-origin resource sharing. A request for a resource (like an image or a font) outside of the origin is known as a cross-origin request. CORS manages cross-origin requests. CORS allows servers to specify who (i.e., which origins) can access the assets on the server, among many other things. Access-Control-Allow-Origin is an HTTP header that defines which foreign origins are allowed to access the content of pages on your domain via scripts using methods such as XMLHttpRequest.
What is Mongooe?
Mongoose is a data modelling library that specifies environment and structure for the data by making MongoDB powerful.
What is MERN Stack?
MERN Stack is also a combination of technologies. It consists of Mongo DB, Express.JS, React.JS, and Node.JS. This is a full-stack based on JavaScript and it offers developers with an end-to-end framework for the development process. MERN Stack is mainly used for faster development of smaller applications as compared with MEAN
Can you explain MEAN Stack Architecture in 5 steps?
MEAN Stack architecture is explained in 5 steps
Step 1 – While Client makes a request first, and is handled by AngularJS.
Step 2 – Next, request enters second stage, where we have Node.js as server-side language and ExpressJS as backend web framework.
Step 3 – Node.js handles the client/server requests and ExpressJS makes request to the database.
Step 4 – In this step the ExpressJS will call MongoDB to set the data, the MongoDB retrieves the requested data and returns to ExpressJS.
Step 5 – In the final step ExpressJS returns the response to Nodejs and in turn to AngularJS and then displays the response to user.
Callback hell is a phenomenon that afflicts a JavaScript developer when he tries to execute multiple asynchronous operations one after the other. Some people call it to be the pyramid of doom.
To do so you have more options:
modularization: break callbacks into independent functions
Using Async.js
Using Promises
Using Async-Await
What is Asyncjs?
Async is a really powerful npm module for managing asynchronous nature of JavaScript. Along with Node.js, it also works for JavaScript written for browsers.
What are Indexes in MongoDB?
Indexes support the efficient execution of queries in MongoDB. Without indexes, MongoDB must perform a collection scan, i.e., scan every document in a collection, to select those documents that match the query statement. If an appropriate index exists for a query, MongoDB can use the index to limit the number of documents it must inspect.
Can you define GridFS in Mongodb?
GridFS is the MongoDB specification for storing and retrieving large files such as images, audio files, video files, etc. It is kind of a file system to store files but its data is stored within MongoDB collections.
What is the syntax of MapReduce Command in MongoDB?
MapReduce is generally used for processing large data sets.
Following is the syntax of the basic mapReduce command −
>db.collection.mapReduce(
function() {emit(key,value);}, //map function
function(key,values) {return reduceFunction}, { //reduce function
out: collection,
query: document,
sort: document,
limit: number
}
)
What is RTO?
RTO stands for Request timeout which means the time of the request is over and the server automatically cancels the request and returns back with this error.
Can you explain the usage of a buffer class in Node.js?
A buffer is a space in memory (typically RAM) that stores binary data. In Node.js the buffer class is used to store raw data as a whole array. But it is similar to a primitive memory assignment outside the V8 heap. Buffer classis a global class that can be easily accessed without importing a buffer module in an application. Buffer class is used because pure JavaScript is not nice to binary data. So, when dealing with TCP streams or the file system, it’s necessary to handle octet streams.
How to convert buffer to json?
By default, the buffer does not return the data in JSON format but most of the APIs responses required data in JSON form. You can use the toJSON method to simply convert the buffer data into JSON.
Can you explain Scaffolding in Express.js?
Scaffolding allows us to easily create a skeleton for a web application. We manually create our public directory, add middleware, create separate route files, etc. A scaffolding tool sets up all these things for us so that we can directly get started with building our application.
What is the syntax of Response JSON method in Express.js?
Syntax:
res.json([body])
This method returns the response in JSON format.
Example:
res.json(null)
res.json({ name: ‘ajeet’ })
What are different types of design patterns?
There are the following three types of design patterns:
Creational patterns: It is concerned with the way we create objects in an object-oriented style. it applies patterns in the way we instantiate a class. They are used to create objects according to builder, singleton pattern, prototype, factory method, abstract factory, etc.
Structural patterns: They make the design easy by introducing a simple way for relationship realization among various entities like adapter, composite, facade, bridge flyweight, decorator, proxy pattern, etc.
Behavioural Patterns: These patterns are used how the objects can interact efficiently without being tightly coupled. Examples: Chain of Responsibility, Mediator, Interpreter, Template, Observer, Iterator, visitor.
What are the most widely used Architectural Patterns?
Architectural Patterns: These patterns are expressing a fundamental structural organization or schema for software systems. Following patterns are widely used Architectural Patterns:
MVC (Model View Controller) Pattern
MVP (Model View Presenter)
REST (Architecture Style)
SOA (Service-Oriented architecture)
EDA (Event-driven architecture)
Client Server
Layered pattern (N-tier Architecture)
Master-Slave Pattern
Monolithic architecture
Pipe Filter Pattern
Peer-Peer Pattern
Space Based Architecture
Broker Architecture
Microservice architecture
What are the Request Object Properties in Express.js?