Why Typescript is the better choice than JavaScript?
➡️ Typescript is an open source language which builds on JavaScript.
➡️ One of the world's most used tools,by adding by adding static type definations.
1. According to StackOverflow servey
➡️ It's mentioned among the five most promising language.
➡️ ...
blog.paragrudani.com2 min read
TypeScript is a superset of JavaScript which primarily provides optional static typing, classes, and interfaces. One of the big benefits is to enable IDEs to provide a richer environment for spotting common errors as you type the code.
Example:
As an example, here's some TypeScript.
class Greeter { greeting: string; constructor (message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } }And here's the JavaScript it would produce
var Greeter = (function () { function Greeter(message) { this.greeting = message; } Greeter.prototype.greet = function () { return "Hello, " + this.greeting; }; return Greeter; })();Notice how the TypeScript defines the type of member variables and class method parameters. This is removed when translating to JavaScript but used by the IDE and compiler to spot errors, like passing a numeric type to the constructor.