The difference between JavaScript and TypeScript

The difference between JavaScript and TypeScript

Claire Nguyen

1. Definition

JavaScript is a programming language used by developers to create interactive websites
JavaScript features dynamic typing and a JIT (just in time) interpreter. JavaScript started out as a client language (executed in a browser), but it was developed to run on the server (using Node.js).

TypeScript is an open source project, considered an enhanced version of JavaScript.
TypeScript is considered a superset of JavaScript, created to solve JavaScript problems in a more optimal way. It still follows the ECMAScript specification but has good support for strongly typed and compile-time error handling. TypeScript supports both static typing and dynamic typing and provides object-oriented like: inheritance, class, scope, namespace, interface and many other modern features.

2. What are the differences and which choice is good?

It can be seen that TypeScript is gradually dominating over JavaScript. Conceptually above, these two languages already have major differences. So it can be seen that TypeScript is also being considered as a good choice today.

To make it more clear, below is a list of some of the features that TypeScript brings to the project.

Below is a theoretical description of the difference between JavaScript and TypeScript.

JavaScript and TypeScript usage statistics table as of early 2023.

3. Syntax

Install command of TypeScript

npm install –g typescript

The definition is different and TypeScript is also somewhat improved than JavaScript, so the beginning of the variable declaration will also be markedly different.

Example 1
In JavaScript:
var name = "ShiftAsia";
In Typescript:
var name: string = "ShiftAsia";

Example 2

In JavaScript:

In Typescript:

4. Summary

TypeScript can be seen as a time-saving solution compared to JavaScript. And TypeScript also follows ECMAScript so it is very familiar to JavaScript programmers. It is also fully compatible with available JavaScript libraries, so for large projects, choosing TypeScript is well worth it.

However, for beginners, choosing 1 of 2 to learn, JavaScript is still a more suitable choice.