Mean Stack Interview Questions
Q. What is Mean Stack?
Mean Stack is the Collection of 4 JavaScript-based technologies like AngularJS, Express, Node, and MongoDB. Mean Stack is a full-stack JavaScript that is used to develop web applications.
Q. What is Node.js?
Node.js is a JavaScript-based runtime platform that executes the JavaScript code on any platform outside of a browser. Node.js is based on Google Chrome’s JavaScript v8 engine.
It is also called a single-threaded program that utilizes the simultaneous models that depend on the event loop circle. Rather than obstructing the execution, it enrolls a callback which enables the applications to run. In this way, according to it, Node.js can deal with all these simultaneous tasks without making the multiple thread execution which can be scaled entirely well.
Q. What Is Mongoose?
Mongoose is an Object Document Mapper (ODM). This means that Mongoose allows you to define objects with a strongly-typed schema that is mapped to a MongoDB document.
Q. What is Routing Guard in Angular?
Angular’s route guards are interfaces which can tell router whether or not it should allow navigation to a requested route. They make this decision by looking for a true or false return value from a class which implements the given guard interface.
Q. How to install express?
To install Express temporarily and not add it to the dependencies list.Run below command to install express
npm install express –save
Q. Explain Mongoose?
Mongoose is a MongoDB Object Data Modeling (ODM) library for NodeJS and MongoDB. It gives a straight-forward, schema/pattern based answer for model your application information. It includes query building, validation, built-in typecasting, business logic hooks and lot more, out of the box.
Q. What is the working of Mean Stack Architecture?
Angularjs being a customer side language in JavaScript so it is the first to process the request made by a customer.
The request at that point enters the Nodejs which is the stage 2 being it the server side language in JavaScript
Then the request enters the phase 3 i.e. Expressjs which makes a request to the database.
After these three phases, the data is retrieved and the response is returned to the Expressjs and this work is done by MongoDB.
Then in the final step, the data is to be returned back to the AngularJS to display the result and this is done by NodeJS which in return takes the data back from the ExpressJS.
Q. How else can the JavaScript code below be written using Node.Js to produce the same output?
console.log(“first”);
setTimeout(function() {
console.log(“second”);
}, 0);
console.log(“third”);
Output:
first
third
second
In Node.js version 0.10 or higher, setImmediate(fn) will be used in place of setTimeout(fn,0) since it is faster. As such, the code can be written as follows:
console.log(“first”);
setImmediate(function(){
console.log(“second”);
});
console.log(“third”);
Q. Why Is Consistent Style Important And What Tools Can Be Used To Assure It?
Consistent style helps team members modify projects easily without having to get used to a new style every time. Tools that can help include Standard and ESLint.Au
Q. How to Update Node (Windows/macOS) Using Installers on Nodejs.org?
The Node.js downloads page includes binary packages for Windows and macOS — but why make your life more difficult? The pre-made installers — .msi for Windows and .pkg for macOS — make the installation process unbelievably efficient and understandable. Download and run the file, and let the installation wizard take care of the rest. With each downloaded update, the newer versions of Node and npm will replace the older version.
Q. What are the timing features of Node.js?
The Timers module in Node.js contains functions that execute code after a set period of time.
setTimeout/clearTimeout – can be used to schedule code execution after a designated amount of milliseconds
setInterval/clearInterval – can be used to execute a block of code multiple times
setImmediate/clearImmediate – will execute code at the end of the current event loop cycle
process.nextTick – used to schedule a callback function to be invoked in the next iteration of the Event Loop
function cb(){
console.log(‘Processed in next iteration’);
}
process.nextTick(cb);
console.log(‘Processed in the first iteration’);
Output:
Processed in the first iteration
Processed in next iteration
Q. Explain REPL In Node.Js?
REPL stands for “Read Eval Print Loop”. It is a simple program that accepts the commands, evaluates them, and finally prints the results. REPL provides an environment similar to that of Unix/Linux shell or a window console, in which we can enter the command and the system, in turn, responds with the output. REPL performs the following tasks.
READ
It Reads the input from the user, parses it into JavaScript data structure and then stores it in the memory.
EVAL
It Executes the data structure.
It Prints the result obtained after evaluating the command.
LOOP
It Loops the above command until the user presses Ctrl+C two times.
Q. What is CORS and how to enable one?
A request for a resource (like an image or a font) outside of the origin is known as a cross-origin request. CORS (cross-origin resource sharing) 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.
For example, if your server provides both a website and an API intended for XMLHttpRequest access on a remote website, only the API resources should return the Access-Control-Allow-Origin header. Failure to do so will allow foreign origins to read the contents of any page on your origin.
Q. What is Cross Site Scripting (XSS)?
By using Cross Site Scripting (XSS) technique, users execute malicious scripts (also called payloads) unintentionally by clicking on untrusted links and hence, these scripts pass cookies information to attackers.
Q. How to bundle an Angular app for production?
OneTime Setup:
npm install -g @angular/cli
ng new projectFolder creates a new application
Bundling Step:
ng build –prod (run in command line when directory is projectFolder)
flag prod _bundle for production
bundles are generated by default to projectFolder/dist/
Q. What’s new in Angular 6 and why shall we upgrade to it?
Angular Elements : Angular Elements is a project that lets you wrap your Angular components as Web Components and embed them in a non-Angular application.
New Rendering Engine: Ivy – increases in speed and decreases in application size.
Tree-shakeable providers : a new, recommended, way to register a provider, directly inside the @Injectable() decorator, using the new providedIn attribute
RxJS 6: Angular 6 now uses RxJS 6 internally, and requires you to update your application also. RxJS released a library called rxjs-compat, that allows you to bump RxJS to version 6.0 even if you, or one of the libraries you’re using, is still using one of the “old” syntaxes.
Q. What is AOT?
The Angular Ahead-of-Time compiler precompiled application components and their templates during the build process. Apps compiled with AOT launch faster for several reasons.
Application components execute immediately, without client-side compilation.
Templates are embedded as code within their components so there is no client-side request for template files.
You don’t download the Angular compiler, which is pretty big on its own.
The compiler discards unused Angular directives that a tree-shaking tool can then exclude.
Q. What is Redux and how does it relate to an Angular app?
Redux is a way to manage application state and improve maintainability of asynchronicity in your application by providing a single source of truth for the application state, and a unidirectional flow of data change in the application. ngrx/store is one implementation of Redux principles.
Q. What is a Grid System in CSS?
A grid system is a structure that allows for content to be stacked both vertically and horizontally in a consistent and easily manageable fashion. Grid systems include two key components: rows and columns.
Some Grid Systems:
- Simple Grid
- Pure
- Flexbox Grid
- Bootstrap
- Foundation
Q. How is responsive design different from adaptive design?
Both responsive and adaptive design attempt to optimize the user experience across different devices, adjusting for different viewport sizes, resolutions, usage contexts, control mechanisms, and so on.
Responsive design works on the principle of flexibility — a single fluid website that can look good on any device. Responsive websites use media queries, flexible grids, and responsive images to create a user experience that flexes and changes based on a multitude of factors. Like a single ball growing or shrinking to fit through several different hoops.
Adaptive design is more like the modern definition of progressive enhancement. Instead of one flexible design, adaptive design detects the device and other features, and then provides the appropriate feature and layout based on a predefined set of viewport sizes and other characteristics. The site detects the type of device used, and delivers the pre-set layout for that device. Instead of a single ball going through several different-sized hoops, you’d have several different balls to use depending on the hoop size.
Q. What’s the difference between a blue/green deployment and a rolling deployment?
In Blue Green Deployment, you have TWO complete environments. One is the Blue environment which is running and the Green environment to which you want to upgrade. Once you swap the environment from blue to green, the traffic is directed to your new green environment. You can delete or save your old blue environment for backup until the green environment is stable.
In Rolling Deployment, you have only ONE complete environment. The code is deployed in the subset of instances of the same environment and moves to another subset after completion.
Q. Explain the main difference between REST and GraphQL
The main and most important difference between REST and GraphQL is that GraphQL is not dealing with dedicated resources, instead everything is regarded as a graph and therefore is connected and can be queried to app exact needs.
Q. Could you explain the difference between ES5 and ES6
ECMAScript 5 (ES5): The 5th edition of ECMAScript, standardized in 2009. This standard has been implemented fairly completely in all modern browsers
ECMAScript 6 (ES6)/ ECMAScript 2015 (ES2015): The 6th edition of ECMAScript, standardized in 2015. This standard has been partially implemented in most modern browsers.
For more Click Here