cft

The Ultimate Cheatsheet Typescript vs. JavaScript and Which You Should Use

JavaScript is a scripting language that helps you create interactive web pages, whereas Typescript is a superset of JavaScript. Typescript code needs to be compiled, while JavaScript code doesn't need a compilation. Typescript uses types and interfaces to describe data being used, whereas JavaScript does not. Typescript has a powerful type system. Includes generics & JS features for large-size projects whereas JavaScript is not so comfortable for larger projects. ...


user

Arnold Abraham

3 years ago | 3 min read

The last article you need regarding the differences of both and which is better

Sometimes the desired framework or project forces you to take either JavaScript or Typescript. Angular goes with Typescript, Vue.js uses JavaScript, React can be used with both.

If you don’t use enforcing frameworks, you have the agony of choice. Since JavaScript is the most popular coding language, you’d better know what the differences between JavaScript & TypeScript are.

Difference Between JavaScript and TypeScript

Table created by the author, TypeScript salary, JavaScript salary
Table created by the author, TypeScript salary, JavaScript salary

Key Differences

  • JavaScript is a scripting language that helps you create interactive web pages, whereas Typescript is a superset of JavaScript.
  • Typescript code needs to be compiled, while JavaScript code doesn’t need a compilation.
  • Typescript uses types and interfaces to describe data being used, whereas JavaScript does not.
  • Typescript has a powerful type system. Includes generics & JS features for large-size projects whereas JavaScript is not so comfortable for larger projects.
  • Using the framework Angular forces you to develop in Typescript.
  • Using the framework, AngularJS enables you to use JavaScript; you can also develop in Typescript and then compile it to JavaScript.
  • React is commonly used with JavaScript, but there are ways to use it with Typescript

What is JavaScript?

Picture from freeCodeCamp
Picture from freeCodeCamp

JavaScript is a scripting language used to create interactive web pages.

JavaScript is a dynamic programming language used for web development, web applications, game development, and many more.

It allows you to implement dynamic features on web pages HTML and CSS don’t allow you.

Many browsers use JavaScript as a scripting language for doing dynamic operations on the web.

Any time you see a click-to-show dropdown menu, extra content added to a page, and dynamically changing element colors on a page, to name a few features, you see the effects of JavaScript.

Features of Javascript

  • It’s a cross-platform language
  • It’s used for client-side and server-side
  • It’s a dynamic language: flexible and powerful
  • Strong Testing Workflow
  • Object-Centered but multi-paradigm script language
  • You have ‘the great freedom’ to do whatever you want with any object
  • Client edge Technology.
  • Validation of User’s Input.
  • Case Sensitive format.
  • It’s easy to learn and to start with, lightweight and delicate.
  • Added Dependencies

Why JavaScript?

  • Specially designed tool for small scripts
  • Supports classes & modules.
  • JavaScript runs in any browser.
  • You can extend JavaScript to write large apps
  • Tons of libraries to pick from
  • Frameworks and Packages to enrich and ease your development time

What is Typescript?

Picture from Reddit
Picture from Reddit

TypeScript is an open-source language by Microsoft. It is a modern-age Javascript development language.

It is a compiled language that builds on JavaScript, one of the world’s most used tools, by adding static type definitions.

Types provide a way to describe an object, leading to better documentation, and allows TypeScript to validate your code.

Run it on Node.js or any browser which supports ECMAScript 3 or newer versions.

Typescript provides optional static typing, classes, and interface. Large JavaScript projects can adopt Typescript to bring more robust software and an easily deployable application.

The key element of Typescript is to develop with the newest version of it, although your application might use older JavaScript versions (down to ES3). Hence having the most and best ways to write code and then just transpile it back to an older JS version to support as many devices as possible.

Features of Typescript

  • Maintainability
  • Offered great productivity for developers
  • Shows errors during development
  • Code navigation and bug prevention
  • Code ‘discoverability’ & refactoring
  • Optional Static Type Annotation / Static Typing
  • Additional Features for Functions
  • Supports ES6
  • Supports interfaces, sub-interfaces, classes, and subclasses
  • Scalable HTML5 client-side development
  • Rich IDE available with autocomplete and code navigation features.
  • Class-based object-oriented with the inheritance of private members and interfaces

Why Typescript?

  • Very close to C# (Microsoft invented Typescript, no surprise then)
  • TypeScript supports JS libraries & API Documentation
  • It is a superset of Javascript
  • Typed scripting language
  • TypeScript Code can be converted into plain JavaScript Code of any ECMAVersion
  • Better code structuring and object-oriented programming techniques
  • Allows better development time tool support
  • It can extend the language beyond the standard decorators, async/await
  • TypeScript supports other JS libraries
  • TypeScript is portable

Which is better?

Photo by William Krause on Unsplash
Photo by William Krause on Unsplash

In the end, there will always be the question about the better option.

And like always in life: it depends.

I prefer if you are an inexperienced developer working on a relatively small coding project, then JavaScript might be ideal for you.

If you are more advanced and gained crucial knowledge or expertise, then Typescript is the most preferred option.



Are you annoyed by extremely long video courses? Getting taught knowledge makes you ask yourself: Why am I learning this right now? Visit my ArnoldCode Academy, where you benefit from coding courses that teach you only what you really need to kickstart!

Upvote


user
Created by

Arnold Abraham

Adventures instead of dull tutorials in Full Stack Web and C# Development. Diploma Engineer, Freelancer & Founder of ArnoldCode Academy. Writing on Medium (arnoldcode.medium.com) and on Substack (https://arnoldcodefae.substack.com/?r=e07d1&utm_campaign=pub&utm_medium=web&utm_source=copy).


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles