JavaScript vs TypeScript

Where's Waldo

Okay so now that we have a general sense of what TypeScript is, let’s play a quick game of Where’s Waldo.

In the above screenshot, you can spot the differences between JavaScript & TypeScript in this very simple multiplication program that just prints out the product of two numbers I’ve pre-defined.

What are those differences though? 🤔️

They're types!

So JavaScript has dynamic typing in that a variable declared as a number can be turned into a string where as TypeScript has static typing meaning you declare beforehand what type of value the variable will hold and it doesn’t change.

In that multiplication.ts file, I’m declaring all these variables to be numbers so they cannot be changed to something else.

Contributing to the Guide

This open source guide is curated by thousands of contributors. You can help by researching, writing and updating these articles. It is an easy and fun way to get started with contributing to open source.