What is major difference between javascript and typescript? | Sololearn: Learn to code for FREE!


What is major difference between javascript and typescript?

4/2/2021 9:23:23 AM

Arqum Farooq

2 Answers

New Answer


TypeScript adds a compilation step (comes before run time) and types which are checked during development to help you fight potential bugs before your code gets to run time. You'll hear these two descriptions being thrown around quite often: 1. TypeScript is a superset of JavaScript. 2. TypeScript is just JavaScript with types. These statements are a bit clichéd but they are valid. For 1: This means that TS adds a layer on top of JS to provide extra features, but at the end of the day, once the code reaches its runtime (not compile time), it all becomes JS. All JS is valid TS when it comes to syntax. This doesn't mean that the TS compiler will necessarily be happy with any given piece of JS code. Essentially, TypeScript's extra features try to help you out during development, but at run time, it's JS that gets executed. For 2: Types refers to a key feature that TS gives you. All values have a type. E.g. a variable with a type of string can't be reassigned to hold a non-string value.


Found one on the net in less than 3 seconds https://flatlogic.com/blog/typescript-vs-javascript-the-key-differences-you-should-know-in-2020/