Typescript-201 Flashcards

1
Q

How can we define optional arguments?

A

function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are pipes used for?

A

Pipe asre used to format the data from src and bing them to the directive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which design principle does Service resembles?

A

SRP Single Repsoncibility Principle

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is system js used for?

A

As a config & module loader

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is app.component.ts

A

It is a standard way of specifying the bootstrapping class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is @Component?

A

It is imported from @angular/core and it is used to bootstrap the class in app.component.ts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the syntax and way of using @Component?

A

First import the component from @angular/core

While importing need not to use @ sign as @ mostly specifies that at the notation & aLso if you want to make a class that could be used else where for @

import {component} from ‘@angular/core’

// The @Component takes an object in parenthesis to //invoke
@Component({ // the below are must defined keys of //@Component
  selector : ápp',
  template : 'html code or path to html file'

})

export class AppComponent{ } // Make it available

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is RxJS

A

Reactive Extension for JS

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is RxJS used for?

A

Its a programming with emitting data, sync or async

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is observable in RxJS?

A

Any emitting data from any src(array, api, object) is Observable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Does Observable automatically notifies the observer?

A

Yes the Observable notifies the observer when data starts emitting or arrive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between Observable & Promise?

A

The promise gets the data one time, and you need to invoke the method again, with observable it will emit multiple times

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Can you write a simple Observable code?

A
var obs = Rx.Observale.of(10);
obs.subscribe(function(d){
    console.log(d); // prints 10
 });
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Does Observable has the capability to invoke the error or success block? Say with E.g.

A

Yes

var obs = Rx.Observable.of(10);
obs.subscribe(
    function(d){
 d=   d+d;
}, function(e){

console.log(ërror’’);
}, function(){
console.log(“success”);
}

);

so all three goes into the paren and as args, the success case wont have any args

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does from operator does?

A

It helps convert array into Observable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Can you write one e.g for creating an observer on settimeout ?

A

So Observable is a sort of wrapper around any function. The Observable will be there to act when the data is knocked. So

var timeout : Observable = Observable.create(
(observer: Observer(string)) => {
setTimeout(() // this shows the function itself will be //executed
=> // this shows the projection or giving from one to //another
{
observer.next(“kiran”); // so you omit on observer
}, 2000);

}

)

timeout. subscribe((v) => {
this. name = v;

});

17
Q

How do specify the return type or a var type?

A

export let users : User[] = [{name : “prc””}] ;

so declare : define = assign

18
Q

How can you create a model object?

A

export class Model exteds/implements class/interface {

}

19
Q

What does the get of http returns?

A

It returns an Observable object with Response type

20
Q

What is included in the Response object?

A

basic, CORS, default response headers, method to get the response data as text and as JSON, with other props regarding http response received from the request

21
Q

Where does the response object of http passed to?

A

The response object is passed to the callback function attached to the subscribe object

22
Q

Specify one e.g. of get, put and post of http ?

A

Yes

public get(book : Book) : Observable = function(){
this.http.get(this.url);
this.post(this.url, JSON.stringify(book));
this.http.put(this.url/ ‘${book.id}’, JSON.stringify(book));
}

23
Q

Can we have two directives in one tag

24
Q

What is window.location.href?

A

It will give the current domain

25
Can we access JS Global vars in interpolation tag
Nope
26
What is window.location.href?
It will give the current domain
27
Can we access JS Global vars in interpolation tag
Nope
28
How can we do attribute and property binding?
using [] ,
29
How to generate components in TS?
ng generate [component, module, service], generationg component will auto add into the module