Comp 101 Number

Numbers

What is it?

Exactly what you'd expect -- a number! This data type encompasses integers as well as other real numbers with decimals.


Fun fact: in other lower-level programming languages, like C and Java, numbers are split into integers and non-integers!

How do we use number as a data type in TypeScript?

We use the number keyword to tell our program the type of variable we're creating. Or, we can let the computer assume based on our variable initialization.

let levelOfFun = 10;
let levelOfLameness: number = 10; // This is also fine!