Typescript-101 Flashcards
What is the diff b/w let, var & const?
Var will create a global variable and it is availabel in Global Object
Let will create a global variable, but does not belong to Global Object
Const will create a global Constant and it is not a property of Global Object
What is the advantage of let?
With let you can create block level vars
What is the advantage of const?
const requires intiallization and must not change while time
Can we define objects with let
Yes
Ca we define html templates with let
Yes A good way to do that
How can you define template literals with let?
let obj = { name : "kjskj }"
let templateStr = “Name is” + $(obj.name)
What is arrow function?
Arrow function is one way of writing inline function, like
var sum = (a,b) => { return a+b;}
var sum = (a,b) => a+b;
Does Arrow function retains the Lexical scope of this?
YEs
Write code for a class and constructor?
Class Person {
constructor(name) { // need not define the as var or let
this.name = name;
}
}
Do you add access modifer or return type in function or construtors?
Nope straight to name
How can you extend the class ?
Using keyword extends and use super where required
How can we create an obj of a class?
let obj = new Employee(“sdfsfdee”);
What is Object.create
To do prototypical inheritance without using constructor function
What is the public access modifier?
Use export
What is import do?
To import any exported entity