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
- During development, TypeScript always highlights errors at compilation time, whereas JavaScript highlights errors at runtime.
- JavaScript does not support strongly typed or static typing, whereas TypeScript does.
- Any browser or JavaScript engine can execute TypeScript.
- IntelliSense, which provides active hints as the code is added, is a fantastic piece of tools.
- By defining a module, it has a namespace idea.
DisAdvantages Of TypeScript Over JavaScript
- The compilation of TypeScript code takes a lengthy time.
- Abstract classes are not supported in TypeScript.
- 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
- Modules are not supported in JavaScript.
- It is a scripting language.
- It was Developed by Netscape in 1995.
- Strongly typed or static types are not supported.
- Generics are not supported in JavaScript.
- Optional Paremeters are not supported in Javascript.
- Javascript directly runs on the browser.
- Because it is an interpreted language, the errors are highlighted at runtime.
- In Javascript numbers and string are objects.
- Javascript source file is ."js extension".
Example
<script>
function addNumbers(a, b) {
return a + b;
}
var sum = addNumbers(15, 25);
document.write('Sum of the numbers is: ' + sum);
</script>
TypeScript
- Support is given for modules in TypeScript.
- Object oriented concepts like classes,inheritance are supported in TypeScript.
- It was developed by Anders Hejlsberg in 2012.
- Strongly typed and static typing feature is supported in TypeScript.
- TypeScript supports generics.
- TypeScript supports optional paremeters.
- TypeScript does not directly runs on browser.
- It compiles the code and highlighted errors during the development time.
- In this, number, string are the interface.
- TypeScript source file is in ".ts" extension.
Example
function addNumbers(a, b) {
return a + b;
}
var sum = addNumbers(15, 25);
console.log('Sum of the numbers is: ' + sum);
Top comments (2)
The examples do not make much sense, because both are basically JavaScript. The first one uses tags, which would be used to include it into HTML. These are just removed in the second one. Maybe you can instead add some code in TypeScript, which would not be possible with JS and then show, what it would be like after compiling it.
Thanks for your article anway!
@curiousdev yeah the both examples are quite similar
Typescript works in a different way i have shared the basic structure for understanding that how we can use it.
You are always welcome 🥰!!