TypeScript Interview Questions and Answers (2) - Page 1

Is TypeScript is replacement for JavaScript?

NOTE: This is objective type question, Please click question title for correct answer.
If we compile TypeScript classes they will become JavaScript functions, similarly if we compile Interfaces of TypeScript what output will be generated in compiled .js file?

Interfaces will be used by typscript at compile time, after that they will be removed and they will not be the part of final javascript output.

Eg :
interface IVehicle
{
engine:string;
fuel:string;
}

class Car implements IVehicle
{
constructor (public engine: string, public fuel: string) {
}
}

Above typescript code will compile to following javascript code :
var Car = /** @class */ (function () {
function Car(engine, fuel) {
this.engine = engine;
this.fuel = fuel;
}
return Car;
}());

Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories