JavaScript vs TypeScript.

Isaac Avilez
2 min readDec 16, 2020

--

Every web developer has used JavaScript. It’s used for creating dynamic websites, and adding all the functionality to a properly run website, but not every web developer has used TypeScript. TypeScript is a strongly-typed, object oriented, compiled language, as opposed to JavaScript which is a scripting language. In reality, TypeScript is just JavaScript. What that means is I’m basically saying that TypeScript code is converted into just plain JavaScript code. Typescript code isn’t understood by the browsers, that’s why if you write TypeScript code, it is then compiled, and then converted into JavaScript, and this is known as Trans-piled. JavaScript code is also just TypeScript, and can be converted to by changing the extension from .js to .ts . Even though TypeScript cannot but understood by browsers until it’s been compiled and thus transformed into JavaScript, TypeScript can be run on any browser, device, or in any operating system! TypeScript also supports JavaScript libraries!

Differences between TypeScript and JavaScript:

  • TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
  • TypeScript is known as an Object oriented programming language, as opposed to JavaScript being a scripting language that supports object oriented programming using prototypes than the class inheritance used in other languages, although a class syntax was added to JavaScript ES6.
  • TypeScript is statically-typed as opposed to JavaScript.
  • TypeScript gives support for modules as opposed to JavaScript which doesn’t.
  • TypeScript has an interface, JavaScript does not.

Advantages of using TypeScript over JavaScript:

  • TypeScript points out the compilation errors at the time of development, which means that there will be a lesser chance of running into a discrepancy as opposed to JavaScript.
  • TypeScript which is strongly-typed supports for static typing. Static typing allows for checking type correctness at compile time.
  • TypeScript is JavaScript with additional feature. TypeScript compiler can compile the .ts files into ES3, ES4, and ES5.
  • TypeScript is featured in the Angular framework, and can also be used in React.js library.

Disadvantages of using TypeScript over JavaScript:

  • TypeScript usually takes longer to run because the code has to be compiled.

I hope this blog has helped you understand the differences between JavaScript and TypeScript, below I will put some documentations to further enhance your knowledge of TypeScript!

--

--

No responses yet