Difference Between JavaScript and TypeScript

JavaScript is a popular programming language of the web. It was initially known as LiveScript. TypeScript is a language based on JavaScript. The key difference between Javascript and TypeScript is that JavaScript is a client-side scripting language and TypeScript is an Object-oriented compiled language. Object oriented programming paradigm focuses on data abstractions rather than on the algorithm for handling data. It is based on two main concepts; objects and classes.

CONTENTS

1. Overview and Key Difference
2. What is JavaScript
3. What is TypeScript
4. Similarities Between JavaScript and TypeScript
5. Side by Side Comparison – JavaScript vs TypeScript in Tabular Form
6. Summary

What is JavaScript?

HTML, CSS, JavaScript are the majorly using for web development. Hyper Text Markup Language(HTML) is the markup language which builds the structure of the webpage. It is to create the content of the page such as paragraphs, headlines etc. Cascading Stylesheet (CSS) provides the styling to the webpage to make it presentable. JavaScript is the programming language to make the webpage interactive. JavaScript allows performing form validation, applying animations and creating events.

Figure 01: JavaScript Logo

JavaScript is a client-side scripting language. When the user opens the web browser and asks for a webpage, that request goes to the web server. The web server sends plain HTML and CSS to the web browser. The operating system contains the web browser and that web browser contains webpage and the webpage consists of JavaScript so it runs on the web server.  Browsers such as Safari, Opera, and Chrome contain a JavaScript engine. JavaScript does not support reading and writing to files. It also does not have multithreading and multiprocessing capabilities.

What is TypeScript?

TypeScript is a superset of JavaScript developed by Microsoft. It has all features of Javascript. It uses TypeScript compiler to convert the TypeScript (ts) file to JavaScript file (js). TypeScript is easier to integrate into JavaScript projects. TypeScript also provides static type checking. It allows the programmer to check and assign variables and function types. This feature makes the code easier to read and to prevent bugs. TypeScript has data types such as String, Number, Boolean, Null, Array, Enum, Tuple, and Generics.

Figure 02: TypeScript

The main advantage of TypeScript is that it allows creating class-based objects. Programmers from C++, Java background are much familiar with concepts such as classes, objects, inheritance. When they try to program using JavaScript it can be hard to apply those concepts in JavaScript scenario. To create a class in JavaScript, a programmer should create a function. For inheritance, they have to use, prototypes. However, TypeScript is class-based so it is capable of supporting inheritance, encapsulation, and modifier as an object-oriented programming language.

What are the Similarities Between JavaScript and TypeScript?

  • TypeScript is a superset of JavaScript. All features of JavaScript are available in TypeScript.
  • Both languages are open and cross-platform.

What is the Difference Between JavaScript and TypeScript?

JavaScript vs TypeScript

JavaScript is an interpreter based language to add interactivity to a webpage. TypeScript is a superset of Javascript which compiles into plain JavaScript.
 Language Category
Javascript is a scripting language. TypeScript is an object-oriented programming language.
Compilation
Javascript does not need a compiler. It runs on the web browser. TypeScript requires a TypeScript compiler to convert into a JavaScript file.
Object-Oriented Features
JavaScript is not purely Object Oriented. It is prototype based. It does not have interfaces. TypeScript is an Object-Oriented Programming language and it is class based. Can use classes, Inheritance, interfaces, and modifiers.
Method of Execution
JavaScript runs on client-side. TypeScript runs on client-side as well as server-side.
Static Checking
Javascript does not have static type checking. TypeScript has static type checking.
Modularity
Javascript does not allow supporting modules. Typescript can import files and modules.

Summary – JavaScript vs TypeScript

JavaScript is a  language to create dynamic web pages. It is a lightweight interpreted language which is easy to integrate with HTML and CSS. It is useful for form validation, animation and to add multimedia capabilities to a web page. TypeScript is JavaScript with added features. The difference between JavaScript and TypeScript is that JavaScript is client-side scripting language and TypeScript is an Object Oriented compiled language.

Download the PDF Version of JavaScript vs TypeScript

You can download PDF version of this article and use it for offline purposes as per citation note. Please download PDF version here Difference Between Javascript and Typescript

Reference:

1.Point, Tutorials. “JavaScript Overview.” Www.tutorialspoint.com, Tutorials Point, 15 Aug. 2017. Available here 
2.Point, Tutorials. “TypeScript Overview.” Www.tutorialspoint.com, Tutorials Point, 15 Aug. 2017. Available here 
3.dnfvideo. YouTube, YouTube, 31 Aug. 2016. Available here 

Image Courtesy:

1.’Javascript badge’By Nikotaf – Own work, (CC BY-SA 4.0) via Commons Wikimedia