January 20, 2023

TypeScript and JavaScript – So What’s the Difference?

TypeScript and JavaScript – So What’s the Difference?

If TypeScript is a Superset of JavaScript, what is the difference between them? Here are 3 differences between Typescript and Javascript. These are not the only differences to be sure but if you are just starting out, this should give you a good idea.

  1. TypeScript is known as an Object-oriented programming language whereas JavaScript is a prototype-based language. A very simplified explanation is: In a prototype-based language, object properties and methods can be shared using Objects which can be cloned and extended. However, in a prototype-based language inheritance is limited to Objects (not Classes). For Object Oriented programming languages like TypeScript, you get full class support and access modifiers and type annotations that JavaScript does not have.
  2. Typescript uses Static Typing while JavaScript uses Dynamic Typing. Typescript allows the user to assign a type (like string or number) or can infer the type by how the variable is initialized. With Dynamic Typing, type checks are performed at runtime. This means that you do not have to explicitly declare a variable before it is used. It also means that with TypeScript you are less likely to see runtime errors since the type is checked at compile time. With Dynamically Typed languages all type checks are performed in a runtime.
  3. TypeScript code is compiled by the TypeScript compiler and then run in the browser (Compiled Language), while Javascript is executed by the browser (Interpreted Language). This browser execution typically makes Javascript execution very fast.

Now that you know some of the differences, where are you going to use TypeScript and JavaScript? If you are using or learning front-end technologies like Angular and React, you will need to know how to program with typescript. If you are learning HTML or CSS (also front-end technologies), you will want to know how to program with JavaScript.

Now that you know some of the differences, if you are working with Front-end technologies like Angular and React, or HTML or CSS, contact us to discover more.

Written by Bob Cody

Share post

Call us Now
Scroll to top