• Mon. Dec 23rd, 2024

What is TypeScript? Strongly typed JavaScript

Byadmin

Dec 6, 2024



Despite this key difference from JavaScript, TypeScript can still be executed anywhere JavaScript can run. That’s because TypeScript compiles not to a binary executable, but to standard JavaScript.

TypeScript vs. JavaScript

TypeScript is a superset of JavaScript. While any correct JavaScript code is also correct TypeScript code, TypeScript also has language features that aren’t part of JavaScript. The most prominent feature unique to TypeScript—the one that gave TypeScript its name—is, as noted, strong typing: a TypeScript variable is associated with a type, like a string, number, or boolean, that tells the compiler what kind of data it can hold. In addition, TypeScript supports type inference, and includes a catch-all any type, which means that variables don’t have to have their types assigned explicitly by the programmer.

TypeScript is also designed for object-oriented programming, whereas JavaScript is not. Concepts like inheritance and access control that are not intuitive in JavaScript are easy to implement in TypeScript. In addition, TypeScript allows you to implement interfaces, a largely meaningless concept in the JavaScript world.



Source link