In this article, we will see the comparison of typescript vs JavaScript with advantages and disadvantages.
What is JavaScript
JavaScript is the most widely used HTML and Web programming language. JavaScript is a lightweight, cross-platform object-based programming language. It's used to make dynamic client-side pages. Scripts are programs 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 performed as plain text, and no extra 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 gained prominence as the greatest scripting language. Netscape submitted JavaScript to ECMA in November 1996. (European Computer Manufacturers Association). ECMAScript 2019, which was released in June 2019, is the most recent version of JavaScript.
What is 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 license. It is not a browser-based application. To compile and produce a JavaScript file, you'll need a compiler. The ".ts" suffix refers to the TypeScript source file. By renaming any valid ".js" file to ".ts" we may utilize it. TypeScript is an ES6-based version of JavaScript with a few more capabilities.
History of TypeScript
The typescript was created by Anders Hejlsberg. It was originally made available to the general public on October 1, 2012. The latest version of TypeScript 0.9 was published in 2013 after two years of internal development at Microsoft. TypeScript 4.5.4, which was published on 13 December 2021, is the most recent version.
TypeScript Vs JavaScript
Code Example of JavaScript:
let var = "Hello Welcome to Softhunt.net";
var = 15;
console.log(var);
Code Example of TypeScript:
let var: string = "Hello Welcome to Softhunt.net";
var = 15;
console.log(var);
Advantages of TypeScript over JavaScript
- During development, TypeScript always indicates faults at compilation time, whereas JavaScript reveals issues at runtime.
- TypeScript allows highly typed or static typing, whereas this is not in JavaScript.
- Any browser or JavaScript engine can execute TypeScript.
- Great tooling supports IntelliSense which provides active hints as the code is added.
- It has a namespace concept by defining a module.
The disadvantage of TypeScript over JavaScript
- The compilation of TypeScript code takes a lengthy time.
- Abstract classes are not supported by TypeScript.
- If we launch the TypeScript program in the browser, we'll need to compile it first to convert it to JavaScript.
Conclusion
When comparing the pros and downsides of typescript vs javascript, it can be concluded that both technologies have advantages and disadvantages. Although JavaScript is not a complete coding language, it is used in conjunction with HTML to improve the quality of online pages. In addition, JavaScript is used by thousands of professional developers.
TypeScript, on the other hand, is the language of choice for developers who want to write clean, elegant, concise, and readable code. Not to mention TypeScript's benefits in terms of live error checking and static typing.
Suggested Articles:
Top comments (2)
Where's the TypeScript from the 2nd example of code?
For me seems JavaScript, not TS
I will update it thankyou for pointing it out.