Angular Ionic Interview Questions

JAVASCRIPT

What is hoisting?

Its mechanism

Variable and function declarations are moved to the top of their scope before code execution.

console.log(x) //undefined

var x = 10

console.log(x) // print 10


console.log(y+z) //reference error

let y = 10

const z = 10

---------------------------------------------------------------------------------------------------------------------------

Difference between let and var?

---------------------------------------------------------------------------------------------------------------------------

What are let, var, and const in javascript?

let - block scoped, redeclared not supported in same scope

const - block scoped, redeclared or redesigned are not supported

var - function scoped, redeclared and redesigned are supported


function scope 

function test(){
var a = 10;
var a = "mani";  //redeclared and redesigned are supported with the scope
}

block scope

if(test){

let a = 10;
let b = 11; //error

if(tt){
let b = 12; //working
}

}

if(test)
{
const a = 10;
a = 11; //facing error
const a = "mani"; //facing error
}
---------------------------------------------------------------------------------------------------------------------------
Data types in javascript
Primitive data types can store only a single value. To store multiple and complex values, non-primitive data types are used.
Primitives datatypes: String, Number, Symbol, Boolean, BigInt, Null, Undefined
Non-Primitive datatype : Object
---------------------------------------------------------------------------------------------------------------------------

Difference of == and === in javascript?

== - compare the value

=== - compare the value and data type

---------------------------------------------------------------------------------------------------------------------------

Implicit Type Coercion?

automatically convert the value from one datatype to another datatype

var a = 10

var b = "mani"

a+b //"10mani"

---------------------------------------------------------------------------------------------------------------------------

Javascript is dynamically typed language

type of variable are checked while compile-time

---------------------------------------------------------------------------------------------------------------------------

What is NaN? - Not a number

---------------------------------------------------------------------------------------------------------------------------

Passed by value and passed by reference?

Primitive data types are passed by value

Non-primitive data types are passed by reference


Passed by value in primitive data types only

a = 10 //memory reference 101

b = a //b memory reference 102, it will copy the value from a and stored in new memory


Passed by reference in non-primitive data types only

var obj1 = {id:1, name: "mani"}

var obj2 = obj1

These are used same memory reference

---------------------------------------------------------------------------------------------------------------------------

Purpose of "this" keyword in javascript? - this will refer the current object variables


var obj = {

    name:  "vivek",

    getName: function(){

    console.log(this.name);

  }

}

        

obj.getName();

---------------------------------------------------------------------------------------------------------------------------

What is call(), apply() and bind() methods? - predefined methods

call() method allows an object to use the method (function) of another object.

call() accept argument

function saySomething(message){

  return this.name + " is " + message;

}

      

var person4 = {name:  "John"};

saySomething.call(person4, "awesome");

// Returns "John is awesome"    

apply() - its same like call but its accept the argument are array

bind() - This method returns a new function, where the value of “this” keyword will be bound to the owner object, which is provided as a parameter.

---------------------------------------------------------------------------------------------------------------------------

Scopes in Javascript?

There are three types of scopes in JS:

Global Scope

Local or Function Scope

Block Scope

---------------------------------------------------------------------------------------------------------------------------

Expansion of DOM? - Document object model

---------------------------------------------------------------------------------------------------------------------------

What is arrow function?

its introduced ES6 verions

val r = function(a,b){

return a+b

}


var arrowab = (a,b) => a+b;

---------------------------------------------------------------------------------------------------------------------------

What is Event listening in javascript?

---------------------------------------------------------------------------------------------------------------------------

What is onload() and purpose?

---------------------------------------------------------------------------------------------------------------------------

Javascript Sequence:

function showData(data){

document.getElementById("demo").innerHtml = data;

}


function addData(num1, num2){

let sum = num1 + num2;

showData(sum);

}


addData(2,3);

---------------------------------------------------------------------------------------------------------------------------

What is SCSS? - Sassy Cascading Style Sheets


ANGULAR

Types of observables in rxjs angular?

1) Subject

2) Behaviour subject

3) Replay subject

4) AsyncSubject

---------------------------------------------------------------------------------------------------------------------------

What is Subject?

Subject is special type of observables

---------------------------------------------------------------------------------------------------------------------------

Difference of Subject and Observable?

observable support single casting

subject support multiple casting

---------------------------------------------------------------------------------------------------------------------------

Types of subjects:


Subject

BehaviourSubject - We can set initial/default value and remember previous data

ReplaySubject - Remember custom number of previous data

AsyncSubject - Its will print only final data while complete it

---------------------------------------------------------------------------------------------------------------------------


Angular Lifecycle hooks?

ngOnChanges

ngOnInit

ngDoCheck

ngAfterViewInit

ngAfterViewChecked

ngAfterContentInit  (ng-content)

ngAfterContentChecked

ngOnDestroy


Eg:

parent ngOnInit

parent ngOnChanges

parent ngondocheck

content ngonint

content ngonchanges

content ngondocheck

parent ngonAfterContentInit

parent ngOnAfterContentChecked

child ngOnChanges

child ngoninit

child ngondocheck

child ngonAfterViewInit

child ngOnAfterViewChecked

content ngOnAfterViewInit

content ngOnAfterViewChecked

parent ngOnAfterViewInit

parent ngOnAfterViewChecked

parent ngOnDestroy

content ngOnDestroy

child ngOnDestroy

---------------------------------------------------------------------------------------------------------------------------

What is Angular Binding?

String Interpolation - One way data binding

Property Binding - [] - One way data binding in html widgets

Event Binding - () - One Way data binding from html to ts

([ngModel]) - Two way data binding

---------------------------------------------------------------------------------------------------------------------------

What is directive and types of directives?

component directives - <ng-app></ng-app>

structure directives - ngIf, nfFor

Attribute directive - ngModel, ngClass, ngStyle

custom directive - change element of dom style and behaviour

@Directive({

selector : "[test]"

})


class BGClass {}

---------------------------------------------------------------------------------------------------------------------------

What is pipe?

---------------------------------------------------------------------------------------------------------------------------

What are the default pipes in angular?

---------------------------------------------------------------------------------------------------------------------------

What are difference between ngFor, ngForOf?


<div *ngFor="let item of Items">

<template [ngFor]="let item of items">

<template ngFor let-item="variable" [ngForOf]="items">


ngForOf - type safe - allow generic type

ngFor - not type safe


ngFor is not iterate the ng-container, ng-content directly

so we use ngForOf

ngFor is structural directive, its replace to ng-repeat

---------------------------------------------------------------------------------------------------------------------------

Different of observable vs promise?

Observable is lazy, multiple value can passed, can be cancelled

Promise is eager, single value emitting, not lazy, cann't cancelled,


const obs = new Observable.create(

observer =>{

observer.next(),

observer.error(e),

observer.complete()

})


obs.subscribe(x => console.log(x))


const promise = new Promise((resolve, reject)=>{

resolve("test")

reject("error")

})


promise.then(x => console.log(x))

---------------------------------------------------------------------------------------------------------------------------

What is HttpInterceptor?


intercept(req: HttpRequest, next: HttpHandler)


req.url

req.clone({

headers: req.headers.set()

});

next.handle()

---------------------------------------------------------------------------------------------------------------------------

What is difference of Authorization and Authentication?

---------------------------------------------------------------------------------------------------------------------------

What is Authguard?

---------------------------------------------------------------------------------------------------------------------------

What is difference of canActivated, canLoad in angular?

---------------------------------------------------------------------------------------------------------------------------


IONIC

ionic lifecycle hooks

ngOnInit

ionViewWillEnter

ionViewDidEnter

ionViewWillLeave

ionViewDidLeave

ngOnDestroy


Eg: page 1 -> page 2

ngOnInit

ionViewWillEnter

ionViewDidEnter

ngOnInit - 2

ionViewWillLeave

ionViewWillEnter - 2

ionViewDidEnter - 2

ionViewDidLeave - 1

---------------------------------------------------------------------------------------------------------------------------

The syntax for Angular project creation?

ng new projectName

---------------------------------------------------------------------------------------------------------------------------

Ionic Project Creation?

ionic start projectName black/tabs --type=ionic-angular --capacitor/cordova

---------------------------------------------------------------------------------------------------------------------------

What is capacitor?

Capacitor is support progressive web app (Elector, android, ios)

Cordova for web application

---------------------------------------------------------------------------------------------------------------------------

How to create custom cordova plugin?

Using Plugman framework

---------------------------------------------------------------------------------------------------------------------------

Ios Certificates:

Development,

AdHoc,

Enterprise,

AppStore

---------------------------------------------------------------------------------------------------------------------------

ionic 4 folder structure?


e2e

node_modules

platforms

plugins

src

resources

www

angular.json

config.xml

package.json

ionic.config.json


src


app

assets

environments

theme

global.scss

index.html

main.ts

karma.config.js

polyfills.ts

test.ts

---------------------------------------------------------------------------------------------------------------------------

Difference between ionic 3 vs ionic 4?


karma.conf.js - Ionic 4

main.ts - Ionic 4

polyfills.ts - Ionic 4

angular.json - Ionic 4


ionViewDidLoad, ionViewCanEnter, ionViewCanLeave is removed in ionic 4


Angular router is used instead of navcontroller in ionic 4


promised used for alertController in ionic 4 with async and await

async is used to return the promise

await is used wait for the promise

---------------------------------------------------------------------------------------------------------------------------

Type of forms in angular?

Template-driven Form

Reactive Form

---------------------------------------------------------------------------------------------------------------------------

Form Module:

ngForm, ngModel, ngSubmit

---------------------------------------------------------------------------------------------------------------------------

Reactive Form Module:

FormGroup,

FromControlName

---------------------------------------------------------------------------------------------------------------------------

What is Injectable annotation in angular?

@Injectable({

providedIn:"root"

})

---------------------------------------------------------------------------------------------------------------------------

How to update the appstore build after change bundle id?

---------------------------------------------------------------------------------------------------------------------------

What is lazy loading?

---------------------------------------------------------------------------------------------------------------------------

What is canload in authguard?

canload - prevent the unauthorized user to entire module of app, used in lazy loading

canactivate - is used to prevent an unauthorized user, used in eager loading

canload - is not download the chunk.js file, its hidden difference

---------------------------------------------------------------------------------------------------------------------------

Syntax of lazy loading?

const routes: Routers =[{

path : "login",

loadChildren()=> import(../LoginModule).then(m => m.loginModule)

component: LoginComponent

}]

AppModule.forRoute(routes)

-------------------------------------------------------------------------------------------------------------------------

How to install the pod in ios?

sudo gem install cocoapods

pod install

pod deintegrate

pod repo update

-------------------------------------------------------------------------------------------------------------------------

What is interceptor?

HttpInterceptor is interface, it has intercept method with httprequest, httphandler

req.clone(setHeader())

next.handle(req)

-------------------------------------------------------------------------------------------------------------------------

Usecase of handle data in onload?

onload="init(data)"

-------------------------------------------------------------------------------------------------------------------------

Angular lifecycle, Which lifecycle hooks triggered first?

ngOnInit

-------------------------------------------------------------------------------------------------------------------------

Ionic.config.xml purpose?

name of app, integration is cordova/capacitor, type = ionic-angular

-------------------------------------------------------------------------------------------------------------------------

Ionic 4 project structure?

e2e, src, platform, resources, plugins, www, node_modules

src, app, environments, theme, assets, karma.config.js, main.ts, global.scss, index.html

-------------------------------------------------------------------------------------------------------------------------

Internal testing vs test flight in ionic app?

-------------------------------------------------------------------------------------------------------------------------

How to integrate third-party library in ios?

-------------------------------------------------------------------------------------------------------------------------

How to load 1000 data without lacking in ionic - collection-repeat directive

-------------------------------------------------------------------------------------------------------------------------

How to know platform type in ionic

-------------------------------------------------------------------------------------------------------------------------

How to do test cases in ionic?

How to create a custom plugin in Cordova?

What is the difference between cordova vs capacitor?

What is the difference between ionic 3 and ionic 4?

What is lazy loading?

What are the lifecycle hooks ionic 4?

How to do a list of data in ionic?

What is the difference between ionic prepare and ionic build?

How to deploy the android and ios build?

What is the difference between async and await?






Comments

Popular posts from this blog

Google Assistant Implementation in Android application with app actions