TypeScript Interview Quiz
TypeScript Interview Questions
- What is TypeScript?
Ans: It is open source, strongly typed, object oriented and compiled language developed by Microsoft.
- Why use TypeScript?Ans: There are following reasons :
1.) It is open source.
2.) TypeScript simplifies JavaScript code.
3.) It provides static type checking.
4.) It makes code easier to read and understand.
5.) TypeScript is nothing but JavaScript with some additional features.
6.) TypeScript will save developers time.
7.) TypeScript is a superset of ES3, ES5, and ES6.
- What are additional feature of TypeScript?Ans: 1.) Functions with optional parameters(optional parameter using ?).
Example : function echo(a:number, b:string, c:number?): any{}
2.) Generics support.
3.) Modules support.
4.) Support inheritence property.
5.) enum type support.
6.) Interface support.
- TypeScript CompilerAns:TSC convert the typescript file into javascript file.
- A JavaScript file cannot be renamed to a TypeScript file.Ans: False.
- The value of TypeScript is writingAns: Safer code
- TypeScript was made public byAns: Microsoft.
- We can rename a .js file to .ts file generallyAns: True
- Typescript compiler tsc converts code toAns: JavaScript
- TypeScript is a__Ans: Super-set of JavaScript
- TypeScript isAns: Object Oriented.
- Which type is assigned to variables with null typeAns: None of these
- Type Annotations allows us toAns: Record the intended contract of the function or variable.
- Is typeScript reduces the bugs?Ans: Yes, It reduce the bugs like null handling, undefined etc.
- Function overloading.Ans: TypeScript allows to define overloaded functions and this helps distinct implementations of a function depending on the parameter.
- Generics allows to accept arguments of__Ans: Different types.
- A type system is a set ofAns: Rules.
- Static type checking is done at _____________.Ans: Compilation time.
- Annotations can be implemented asAns: length: number.
- During run time, ______________checking is done.Ans: Dynamic Type.
- Which of the following is the right way of defining enum?Ans: All of these
- Generics are ______.Ans: Template
- Which of the following is the wrong way of defining variables in TypeScriptAns: var 10231.
- Which of the two is used appropriately in JavaScript code:Ans: function reverse(s: string) : string;
- Value && typeof value == "DataType" is used forAns: Overloading
- Inheritance is implemented by using which keyword?Ans: extends.
- " var jarvis = function (x: number, y?: number): number {} " showcasesAns: both.
- Syntax for a decorator isAns: @symbol.
- Which of the following are inherited from base class?Ans: all of these.
- Which keywork is used to access base class properties?Ans: super.
- The code snippet " if (value && typeof value == "string") {}; is used for ______________.Ans: Overloading
- Which keyword is used for Inheritance in TypeScript?
Ans: extends - TypeScript uses prototypical inheritance instead of classical inheritance.
Ans: False - During compilation, TypeScript code gets converted to assembly language.
Ans: False - How can we access a class of module from outside?
Ans: By using "export" - During compilation time, _______checking is done.
Ans: Static type - __________ in command line enables experimental support for decorators.
Ans: "experimentalDecorators": true. - Which is not a type that TypeScript supports?
Ans: integer. - Type System is a _____________.
Ans: Set of rules - What is true about Mixins in TypeScript?
Ans: All of these - Accessing a class of a module from outside is impossible in TypeScript.
Ans: False - Optional parameter can be defined by using "?".
Ans: True - Likewise other elements, Interface of TypeScript is usually converted to JavaScript.
Ans: False - Enum organises _______________.
Ans: Set of related values - TypeScript is a open source programming language.
Ans: True - To a declaration, at most how many decorators can be applied?
Ans: Multiple - Compiled .js of .ts containing class will also have class.
Ans: False - What is the form associated with @expression?
Ans: Decorators
Comments
Post a Comment