Search Tutorials

Top TypeScript (2021) Interview Questions | JavaInUse

Top TypeScript frequently asked interview questions.

In this post we will look at TypeScript Interview questions. Examples are provided with explanations.

Q: What is TypeScript?

A : TypeScript is JavaScript for application-scale development. TypeScript is a strongly typed, object oriented, compiled language. It was designed by Anders Hejlsberg (designer of C#) at Microsoft. TypeScript is both a language and a set of tools. TypeScript is a typed superset of JavaScript compiled to JavaScript. In other words, TypeScript is JavaScript plus some additional features.

Q: What are the features of TypeScript?

A :

Features of TypeScript

  • TypeScript is just JavaScript. TypeScript starts with JavaScript and ends with JavaScript. TypeScript adopts the basic building blocks of your program from JavaScript. Hence, you only need to know JavaScript to use TypeScript. All TypeScript code is converted into its JavaScript equivalent for the purpose of execution.
  • TypeScript supports other JS libraries. Compiled TypeScript can be consumed from any JavaScript code. TypeScript-generated JavaScript can reuse all of the existing JavaScript frameworks, tools, and libraries.
  • JavaScript is TypeScript. This means that any valid .js file can be renamed to .ts and compiled with other TypeScript files.
  • TypeScript is portable. TypeScript is portable across browsers, devices, and operating systems. It can run on any environment that JavaScript runs on. Unlike its counterparts, TypeScript does not need a dedicated VM or a specific runtime environment to execute.

Q: What are the Components of TypeScript?

A : A TypeScript consists of 3 components -
  • Language
  • TypeScript Compiler
  • TypeScript Language Service

Q: How to convert a String to number in TypeScript?

A :
var a = "32";
var b: number = +a;

Q: What is difference between Interfaces and Types in TypeScript?

A : One difference is that interfaces create a new name that is used everywhere. Type aliases does not create a new name - for instance, error messages do not use the alias name.
Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive, union, and intersection types.

Q: How to remove an array item in TypeScript?

A :
const index = dataArray.indexOf(key, 0);
if (index > -1) {
   dataArray.splice(index, 1);

See Also

Spring Boot Interview Questions Apache Camel Interview Questions Drools Interview Questions Java 8 Interview Questions Enterprise Service Bus- ESB Interview Questions. JBoss Fuse Interview Questions Angular 2 Interview Questions