Understanding TypeScript and es6

TypeScript is a superset of JavaScript that compiles to clean the JavaScript output.

As its name suggests, TypeScript implies type languages, which require us to specify data types during data declaration in code. This can be seen in different languages, such as Java, C#, and so on. In TypeScript, the declaration of a variable is done using an annotation colon, as follows:

let name : string = "Bruno";

Secondly, JavaScript contains most (not all) of the object-oriented features. So, it can be implemented semantically, but there is no provision syntactically . For example, an important feature of OOP is the encapsulation; let's compare it:

TypeScript code JavaScript code (ES5)
class GreetTheWorld {
greet() {
return "Hello World";
}
}
var GreetTheWorld = (function () {
function GreetTheWorld() {
}
GreetTheWorld.prototype.greet = function () {
return "Hello World";
};
return GreetTheWorld;
}());

Eventually, the frameworks that uses TypeScript as its primary scripting language compiles (transpiles) it into es5 JavaScript. The new es6 acts as a bridge between es5 and TypeScript. To date, es6 has gradually implemented TypeScript features into JavaScript for example classes. Knowing this, it will be easy for us to understand the usage of TypeScript in Angular framework. For more in depth learning, we can refer https://www.TypeScriptlang.org/docs/home.html.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.136.142