JavaScript VS TypeScript
Published: 2022-02-04 15:18:35

JavaScript is the most widely used HTML and Web programming language. JavaScript is a lightweight, cross-platform object-based scripting language.It's used to make dynamic client-side pages. Scripts are programmes written in the JavaScript programming language.The scripts are embedded in HTML pages and run in the background when the page loads. It is delivered and executed as plain text, and no special preparation or compilation is required to run it.

## History Of JavaScript
Brendan Eich, a programmer at Netscape Communications Corporation, created JavaScript. It was first released in September 1995 under the name Mocha.However, it was renamed JavaScript to reflect Netscape's use of Java within its browser as it increased in popularity as the greatest scripting language. Netscape submitted JavaScript to ECMA in November 1996. (European Computer Manufacturers Association). ECMAScript 2018, which was released in June 2018, is the most recent version of JavaScript.

## TypeScript
TypeScript is an object-oriented programming language that is free and open-source. It's a superset of JavaScript that's highly typed and compiles to ordinary JavaScript. Microsoft created and maintains TypeScript under the Apache 2 licence. It is not a browser-based application. To compile and generate a JavaScript file, you'll need a compiler. The ".ts" extension refers to the TypeScript source file. By renaming any legitimate ".js" file to ".ts," we can use it. TypeScript is an ES6-based version of JavaScript with a few more capabilities.

## History Of TypeScript
TypeScript was created by Anders Hejlsberg. It was originally made available to the general public on October 1, 2012. The new version of TypeScript 0.9 was published in 2013 after two years of internal development at Microsoft. TypeScript 3.4.5, which was released on April 24, 2019, is the most recent version.

## Advantages of TypeScript Over JavaScript

1. During development, TypeScript always highlights errors at compilation time, whereas JavaScript highlights errors at runtime.
2. JavaScript does not support strongly typed or static typing, whereas TypeScript does.
3. Any browser or JavaScript engine can execute TypeScript.
4. IntelliSense, which provides active hints as the code is added, is a fantastic piece of tools.
5. By defining a module, it has a namespace idea.

## DisAdvantages Of TypeScript Over JavaScript

1. The compilation of TypeScript code takes a lengthy time.
2. Abstract classes are not supported in TypeScript.
3. If we launch the TypeScript programme in the browser, we'll need to compile it first to convert it to JavaScript.

## Some Important Things You must Know About Javascript And TypeScript

##JavaScript

1. Modules are not supported in JavaScript.
2. It is a scripting language.
3. It was Developed by Netscape in 1995.
4. Strongly typed or static types are not supported.
5. Generics are not supported in JavaScript.
6. Optional Paremeters are not supported in Javascript.
7. Javascript directly runs on the browser.
8. Because it is an interpreted language, the errors are highlighted at runtime.
9. In Javascript numbers and string are objects.
10. Javascript source file is ."js extension".

**Example**
```js
<script>
function addNumbers(a, b) {  
    return a + b;  
}  
var sum = addNumbers(15, 25);  
document.write('Sum of the numbers is: ' + sum);
</script>
```

## TypeScript
1. Support is given for modules in TypeScript.
2. Object oriented concepts like classes,inheritance are supported in TypeScript.
3. It was developed by Anders Hejlsberg in 2012.
4. Strongly typed and static typing feature is supported in TypeScript.
5. TypeScript supports generics.
6. TypeScript supports optional paremeters.
7. TypeScript does not directly runs on browser.
8. It compiles the code and highlighted errors during the development time.
9. In this, number, string are the interface.
10. TypeScript source file is in ".ts" extension.

**Example** 
```ts
function addNumbers(a, b) {  
    return a + b;  
}  
var sum = addNumbers(15, 25);  
console.log('Sum of the numbers is: ' + sum);
```