mean interview qa

What do you mean SPA Single Page Application. What Programing language use to implement SPA
  1. SPA is Web Application/ website that interact with user by dynamically rewriting current page rather than loading loading entire page from server.
  2. SPA Avoids interruption of user experience while navigating to successive pages.
  3. All Necessary Code HTML, CSS, JS load with single page load. 
  4. SPA can implemented Using AngularJS, Ember JS, React JS, Knock Out, Vue JS

 

What Do you mean by SSE Server Sent Event

 

  1.  SSE is a technique in which server can initiate Data Transmission to browser/ client.
  2. SSE is better than Web Sockets

 

What are challenges with SPA Model 
  1. SEO crawlers does not execute JS.
  2. Security
  3. Browser history.

 

Ng-Module 
  1. Ng-Module is building block of angular Application.
  2. An App always have at least a Root App Module for bootstrapping and many feature modules.
  3. Ng-Module is a class with decorator @NgModule, It contents
@NgModule({

   declarations: [

      Components

   ],

   imports: [

      Modules

   ],

   providers: [Services],

   entryComponents: [COmponents want to open as popup],

   exports: [Services],

   bootstrap: [AppComponent]

})

export class AppModule { }

 

Component 
  1. A component control a part of web application screen, It  uses MVC architecture ts file Code control view and model, Html with CSS represent view. 
  2. Component is a class with decorator @Component, It contents
@Component({

selector: "my-component",

template: "Hello Angular"/ templateUrl: “./mycomponent.html”,

styleUrls: ['./mycomponent.css']

})

class MyComponent {

}

 

Service
  1. Use for sharable logic. With services, we can access methods and properties across other components in the entire project.
  2. A Service is a class with decorator
import { Injectable } from '@angular/core';

@Injectable()

export class MyserviceService {

   constructor() { }

}
  • Here, the Injectable module is imported from the @angular/core. It contains the @Injectable  method and a class called MyserviceService. We will create our service function in this class.

 

Type Of Data Binding
  1. Event Binding
    1. User Input in target enviroment
  2. Property Binding 
    1. Using Interpolation

 

Routing
  1. Routing basically means navigation between pages.
  2. Routing NGModule provides a service it defines a navigation path among the different application state.
Why to use Routing
  1. To hide actual path
  2. Router can lazy load the module on demand.
  3. Angular router enables navigation from one view to the next view.

How to Use NgIf with NgFor?

Use ng-container directive For Example:

<ng-container *ngFor="let h of heroes">
 <ng-container *ngIf="showSad || h.emotion !== 'sad'">
 <option [ngValue]="h">{{h.name}} ({{h.emotion}})</option>
 </ng-container>
 </ng-container>

Difference between call and apply

Both can be called on functions, which they run in the context of the first argument. In call the subsequent arguments are passed in to the function as they are, while apply expects the second argument to be an array that it unpacks as arguments for the called function. More details visit

http://hangar.runway7.net/javascript/difference-call-apply

 

Both call and apply perform very similar functions: they execute a function in the context, or scope, of the first argument that you pass to them. Also, they’re both functions that can only be called on other functions
setImmediate() vs setTimeout()
  • setImmediate() is designed to execute a script once the current poll phase completes.
  • setTimeout() schedules a script to be run after a minimum threshold in ms has elapsed.

More read https://nodejs.org/uk/docs/guides/event-loop-timers-and-nexttick/

 

process.nextTick()

Basic node js question

please ref https://blog.risingstack.com/node-js-interview-questions-and-answers-2017

What is Es6/ Ecma Script6?

ES6 refers to version 6 of the ECMA Script programming language. ECMA Script is the standardized name for JavaScript, and version 6 is the next version after version 5, which was released in 2011. It is a major enhancement to the JavaScript language, and adds many more features intended to make large-scale software development easier.

view series of vedio for complete explanation with example

Difference between TypeScript and JavaScript

https://www.geeksforgeeks.org/difference-between-typescript-and-javascript/

Why TypeScript is developed while having JavaScript? 

When JavaScript was developed then JavaScript development team introduced JavaScript as a client-side programming language. But when people was using JavaScript then developer get to know that JavaScript can be used as a server-side programming language also. But When JavaScript was growing then the code of JavaScript became complex and heavy. Because of this, JavaScript was even not able to full fill the requirement of Object-oriented programming language. This prevents JavaScript from succeeding at the enterprise level as a server-side technology. Then TypeScript was developed by the development team to bridge this gap.

Features of TypeScript:

  • TypeScript Code is converted into Plain JavaScript Code:: TypeScript code is not understandable by the browsers. Thats why if the code is written in TypeScript then it is compiled and converted the code i.e. translate the code into JavaScript.The above process is known as Trans-piled. By the help of JavaScript code, browsers are able to read the code and display.
  • JavaScript is TypeScript: Whatever code is written in JavaScript can be converted to TypeScript by changing the extension from .js to .ts.
  • Use TypeScript anywhere: TypeScript code can be run on any browser, devices or in any operating system. TypeScipt is not specific to any Virtual-machine etc.
  • TypeScript supports JS libraries: With TypeScript, developers can use existing JavaScript code, incorporate popular JavaScript libraries, and can be called from other JavaScript code.

Difference between TypeScript and JavaScript:

  • TypesScript is known as Object oriented programming language whereas JavaScript is a scripting language.
  • TypeScript has a feature known as Static typing but JavaScript does not have this feature.
  • TypeScript gives support for modules whereas JavaScript does not support modules.
  • TypeScript has Interface but JavaScript does not have Interface.
  • TypeScript support optional parameter function but JavaScript does not support optional parameter function.

Advantages of using TypeScript over JavaScript

  • TypeScript always point out the compilation errors at the time of development only. Because of this at the run-time the chance of getting errors are very less whereas JavaScript is an interpreted language.
  • TypeScript has a feature which is strongly-typed or supports static typing. That means Static typing allows for checking type correctness at compile time. This is not available in JavaScript.
  • TypeScript is nothing but JavaScript and some additional features i.e. ES6 features. It may not be supported in your target browser but TypeScript compiler can compile the .ts files into ES3,ES4 and ES5 also.

Disadvantages of using TypeScript over JavaScript

  • Generally TypeScript takes time to compile the code.
  • TypeScript does not support abstract classes.

Note: tsc : is a typescript compiler(transpiler) that converts typescript code into javascript.

TypeScript

Best Practices:

https://nodejs.org/uk/docs/guides/dont-block-the-event-loop/

For simple tasks, like iterating over the elements of an arbitrarily long array, partitioning might be a good option. If your computation is more complex, offloading is a better approach: the communication costs, i.e. the overhead of passing serialized objects between the Event Loop and the Worker Pool, are offset by the benefit of using multiple cores.

However, if your server relies heavily on complex calculations, you should think about whether Node is really a good fit. Node excels for I/O-bound work, but for expensive computation it might not be the best option.

If you take the offloading approach, see the section on not blocking the Worker Pool.

Must know JavaScript Interview Questions & Answers

What is JavaScript?

JavaScript is a client-side as well as server side scripting language that can be inserted into HTML pages and is understood by web browsers. JavaScript is also an Object based Programming language

Enumerate the differences between Java and JavaScript?

Java is a complete programming language. In contrast, JavaScript is a coded program that can be introduced to HTML pages. These two languages are not at all inter-dependent and are designed for the different intent. Java is an object – oriented programming (OOPS) or structured programming language like C++ or C whereas JavaScript is a client-side scripting language.

What are JavaScript Data Types?

  • Number
  • String
  • Boolean
  • Object
  • Undefined

What is the use of isNaN function?

isNan function returns true if the argument is not a number otherwise it is false.

What are undeclared and undefined variables?

Undeclared variables are those that do not exist in a program and are not declared. If the program tries to read the value of an undeclared variable, then a runtime error is encountered.

Undefined variables are those that are declared in the program but have not been given any value. If the program tries to read the value of an undefined variable, an undefined value is returned.

What is a prompt box?

A prompt box is a box which allows the user to enter input by providing a text box. Label and box will be provided to enter the text or number.

What is ‘this’ keyword in JavaScript?

‘This’ keyword refers to the object from where it was called.

Explain the working of timers in JavaScript? Also elucidate the drawbacks of using the timer, if any?

Timers are used to execute a piece of code at a set time or also to repeat the code in a given interval of time. This is done by using the functions setTimeout, setInterval and clearInterval.

The setTimeout(function, delay) function is used to start a timer that calls a particular function after the mentioned delay. The setInterval(function, delay) function is used to repeatedly execute the given function in the mentioned delay and only halts when cancelled. The clearInterval(id) function instructs the timer to stop.

Timers are operated within a single thread, and thus events might queue up, waiting to be executed.

What is the difference between ViewState and SessionState?

‘ViewState’ is specific to a page in a session.

‘SessionState’ is specific to user specific data that can be accessed across all pages in the web application.

What would be the result of 3+2+”7″?

Since 3 and 2 are integers, they will be added numerically. And since 7 is a string, its concatenation will be done. So the result would be 57.

What do mean by NULL in Javascript?

The NULL value is used to represent no value or no object. It implies no object or null string, no valid boolean value, no number and no array object.

What is the function of delete operator?

The delete keyword is used to delete the property as well as its value.

Example
var student= {age:20, batch:”ABC”};
delete student.age;

What is an undefined value in JavaScript?

  • Variable used in the code doesn’t exist
  • Variable is not assigned to any value
  • Property doesn’t exist

What is the use of Void(0)?

Void(0) is used to prevent the page from refreshing and parameter “zero” is passed while calling.

Void(0) is used to call another method without refreshing the page.

What are JavaScript Cookies?

Cookies are the small test files stored in a computer and it gets created when the user visits the websites to store information that they need. Example could be User Name details and shopping cart information from the previous visits.

What is the ‘Strict’ mode in JavaScript and how can it be enabled?

Strict Mode adds certain compulsions to JavaScript. Under the strict mode, JavaScript shows errors for a piece of codes, which did not show an error before, but might be problematic and potentially unsafe. Strict mode also solves some mistakes that hamper the JavaScript engines to work efficiently.

Strict mode can be enabled by adding the string literal "use strict" above the file. This can be illustrated by the given example:
 function myfunction() {
 "use strict";
 var v = "This is a strict mode function";
 }

Closures in JavaScript? When are they used?

Closure is a locally declared variable related to a function which stays in memory when the function has returned.
For example:

function greet(message) {

console.log(message);

}

function greeter(name, age) {

return name + " says howdy!! He is " + age + " years old";

}

// Generate the message

var message = greeter("James", 23);

// Pass it explicitly to greet

greet(message);

This function can be better represented by using closures

function greeter(name, age) {

var message = name + " says howdy!! He is " + age + " years old";

return function greet() {

console.log(message);

};

}

// Generate the closure

var JamesGreeter = greeter("James", 23);

// Use the closure

JamesGreeter();

Describe the properties of an anonymous function in JavaScript?

A function that is declared without any named identifier is known as an anonymous function. In general, an anonymous function is inaccessible after its declaration.

Define event bubbling?

JavaScript allows DOM elements to be nested inside each other. In such a case, if the handler of the child is clicked, the handler of parent will also work as if it were clicked too.

Is JavaScript case sensitive?

Yes, JavaScript is case sensitive. For example, a function parseInt is not same as the function Parseint.

Write about the errors shown in JavaScript?

  • Load-time errors: The errors shown at the time of the page loading are counted under Load-time errors. These errors are encountered by the use of improper syntax, and thus are detected while the page is getting loaded.
  • Run-time errors: This is the error that comes up while the program is running. It is caused by illegal operations, for example, division of a number by zero, or trying to access a non-existent area of the memory.
  • Logic errors: It is caused by the use of syntactically correct code, which does not fulfill the required task. For example, an infinite loop.

Node Cluster

https://rowanmanning.com/posts/node-cluster-and-express/

Node API Optimization

Memory Caching

Node-caching

memache

Redis caching

Redis 

https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04

https://medium.com/tech-tajawal/introduction-to-caching-redis-node-js-e477eb969eab

Auth Guards/Route Guards in Angular

in angular we can perform authentication using route guards Angular comes with a number of baked-in features which are tremendously helpful for handling authentication. I think my favorite is probably its HttpInterceptor interface, but right next to it would be route guards. Let’s take a look at what Angular’s route guards are and how to use them to help with authentication in your Angular apps. readmore

Java Script Tricky Questions

What will Output of
console.log('1' + 2 + 3 + 4);
Result: 1234

What will Output of
console.log(1 + 2 + 3 + '4');
Result: 64

What will Output of
console.log(1 + true);
Result: 2

What will Output of
console.log(true + true);
Result: 2