JavaScript Vs TypeScript

First here, I want to discuss basics what is JavaScript  and TypeScript, where we use and what are the major differnces of these scripting languages.

JavaScript is the Programming Language for the Web and it can update and change both HTML and CSS. 

JavaScript can calculatemanipulate and validate data. JavaScript is a scripting language that enables you to create dynamically updating content, control multimedia, animate images, and pretty much everything else.

JavaScript was first known as LiveScript, The project originally called as Mocha then rename to Live Script and finally when Netscape and Sun did license agreement, it was again renamed to JavaScript. It got the ECMA standard in 1997, possibly because of the excitement being generated by Java. JavaScript made its first appearance in Netscape 2.0 invented by Brendan Eich  in 1995 with the name LiveScript. The general-purpose core of the language has been embedded in Netscape navigator, Internet Explorer, and other web browsers.It is used in web development for enhancing HTML Pages.

When we get to know that  JavaScript can be used as client side as well as a server-side programming language also. But When JavaScript was growing then the code of JavaScript became complex and heavy. Because of this, JavaScript was even not able to full fill the requirement of Object-oriented programming language. This prevents JavaScript from succeeding at the enterprise level as a server-side technology. Then TypeScript was developed by the development team to bridge this gap.

TypeScript  is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java. The popular JavaScript framework Angular 2.0 is written in TypeScript. TypeScript can help programmers to write object-oriented programs and have them compiled to JavaScript, both on server side and client side.It is designed by Anders Hejlsberg, designer of C# at Microsoft. It is Licensed under Apache 2.

TypeScript Environment SetUP: It is an Open Source technology. We can run on any browser, any host, and any OS. We will following  the tools to write and test a Typescript program.

Editor:  First we write our source code with the help of Text editor  Some of the editors include Windows Notepad, Notepad++, Emacs, vim or vi, etc. Editors used may vary with Operating Systems. The source files  we are typically named with the extension .ts.

Compiler: The TypeScript compiler is itself a .ts file compiled down to JavaScript (.js) file. The TSC (TypeScript Compiler) is a source-to-source compiler (transcompiler / transpiler).

TypeScript Compiler

Here TSC generates a JavaScript version of the .ts file passed to it. Means, the TSC produces an equivalent JavaScript source code from the Typescript file given as an input to it. This process is termed as transpilation.

However, the compiler rejects any raw JavaScript file passed to it. The compiler deals with only .ts or .d.ts files.

Node.js: Node.js is one of the open source, cross-platform runtime environment for server-side JavaScript. Node.js is required to run JavaScript without a browser support. It uses Google V8 JavaScript engine to execute code.

Node is available  in this link:

TypeScript on Windows Installation:

Follow the steps given below to install Node.js in Windows environment.

Step 1 − Download and run the .msi installer for Node.

Download and Run Installer

Step 2 − To verify if the installation was successful, enter the command node –v in the terminal window.

Verify Installation

Step 3 − Type the following command in the terminal window to install TypeScript.

npm install -g typescript

Differences between JavaScript and TypeScript:


  1. JavaScript is a lightweight,interpreted programming language Whereas Typescript is a strongly
    type object-oriented compile language.
  2. Syntax: In JavaScript all the statements are written within Script tagIt tells the browser program to start
    interpreting all the text between these tags as a script<script>// javascript code</script>.                             In TypeScript defines a set of rules for writing programs.Every language specification defines its own syntax. A
    Typescript program is composed of −

    • Modules
    • Functions
    • Variables
    • Statements and Expressions
    • Comments
  3. TypesScript is known as Object oriented programming language whereas JavaScript is a scripting language.
  4. TypeScript has a feature known as Static typing but JavaScript does not have this feature.
  5. TypeScript has Interface but JavaScript does not have Interface.
  6. TypeScript support optional parameter function but JavaScript does not support optional parameter function.

JavaScript ex:-

(“Hello World!”)

TypeScript ex:-

var message:string = “Hello India”console.log(message)On compiling, it will
generate following JavaScript code.
//it Generated by
typescript 1.8.10
var message = “Helloindia”;

  • The first line declares a variable by the name message. Variables are a way to save values in a program.
  • Second line prints the variable’s value to the prompt. Here, console refers to the terminal window. The function log () is used to display text on the screen.

JavaScript is preferable to use in relatively small coding projects. Since Typescript is an object-oriented
language. Which makes our code more consistency, clean, simple and reusable. So it should better to use typescript for developing large projects.TypeScript does not support abstract classes.

JavaScript has a huge active community of developers which make it more popular language. and It supports native browsers. Whereas for Typescript will first compiled and convert to javascript. Which is creating one extra step. With raw javascript, the lines of code are more so it difficult to maintain and make it error free when the code size increases than its counterpart. and its more Flexibility.

TypeScript it is Static Typing useful for large Coding Projects. Better for collaboration.o When large coding projects have many developers. In that time there is a chance of messier coding. And a number of errors increases which makes the handling difficult. So Type safety has a feature to detect errors during coding time. Which makes more efficient code and also we can debug it easily. it has better productivity. Features like – dynamic typing, auto-completion are helped developer’s to boost their productivity.


Leave a Reply

Your email address will not be published. Required fields are marked *