The Difference Between JavaScript and TypeScript

The Difference Between JavaScript and TypeScript

Do you know the difference between the JavaScript and TypeScript ?

Β·

3 min read

Holaa! codersπŸ‘‹ Welcome to my Blog!!

hello-welcome.gif

Today, we're going to take a look at some basic difference JavaScript and TypeScript in my experience.

Table of Contents 🌊

  • Difference between Static-typed and dynamically-typed language.
  • What does JavaScript do?? 😍
  • What does TypeScript do?? 😍
  • Summary 😎

Let's go πŸš€

Let's understand what is Dynamic and Static typed language πŸ‘‡

Static-typed🧐

  • Static typing, as is found in languages like Java, C, C++ and Go.
  • It is considered a relatively risk-averse approach to coding, mainly since the type checking process occurs at compile time.
  • Since a we can't even run code unless it passes these type checks, it forces them to fix these errors up front and, ultimately, maintain cleaner code.

For example, imagine a developer types the following in Java:

String varX = 10;
  • The variable varX was declared using the type string, but subsequently assigned a number 😫

However, in this case, the Java compiler will detect the mismatch, stop compiling the code and announce the error.😿

But, Sometimes it would be hectic to check πŸ₯² every bug , but it's very useful in large applications. 🀭

Now , Let's see Dynamically-typed πŸ‘‡

  • Dynamically typed language are called as weakly-typed language that means it gives error at run time i.e. after execution . For Example :
varX = 10
print(varX)
  • Since the method print can't accept a numeric variable as an argument, this will produce an error. However, despite the typo, the compiler doesn't concern itself with the variable type and will still allow the program to run.
  • That's why It allow developers a lot more freedom when it comes to building programs.

But....But....But....!😝

wait.gif

This practice can quickly lead to lazy coding practices that will cause bugs and breakages to spread through code. Over time, these bugs will only become more buried and harder to find. This sucks more when we start finding bugs πŸ˜’πŸ˜†

laugh-laughing.gif

Now let's see the difference of JavaScript and TypeScript :🧐

ts.png What is JavaScript and What does it do? 🧐

  • JavaScript is a dynamically typed language and also lightweight.
  • And now you know about Dynamically Typed language.πŸ₯³
  • So, that's why It also not detects error while compiling the code.
  • we can directly use in browser .
  • complex and heavy and that's why not useful in large applications.

What is TypeScript What does it do? πŸ˜΅β€πŸ’«

  • TypeScript code is not understandable by the browsers. That’s why if the code is written in TypeScript then it is compiled and converted the code i.e. translate the code into JavaScript and this is known as Trans-piled.
  • We can write JavaScript Code in TypeScript but in JavaScript we can't implement TypeScript πŸ₯²
  • TypeScript has a feature known as Static typing but JavaScript does not have this feature.

So , Now you know why You should learn TypeScript and personally I love TypeScript . πŸ˜œβ€οΈβ€πŸ”₯

yay.gif

Summary β€οΈβ€πŸ©Ή

TypeScript is nothing but JavaScript and some additional features i.e. ES6 features. It may not be supported in your target browser but the TypeScript compiler can compile the .ts files into ES3, ES4, and ES5 also. JavaScript is good for small applications but complex in large applications.

and that's all, folks! πŸ₯³πŸ₯³ Thank you for reading this far!! I hope this helped clear up any confusion you had about JavaScript and TypeScript🧑 feel free to drop me any questions or shoot me a DM on Twitter if you're still confused! I just started learning TypeScript from two days and this is literally awesome.πŸ˜‹

Find me on Twitter πŸ‘€

Β